mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Merge pull request #4272 from flysand7/os2-noquote
[os2/process]: Don't quote arguments unless needed
This commit is contained in:
@@ -650,6 +650,7 @@ _build_command_line :: proc(command: []string, allocator: runtime.Allocator) ->
|
|||||||
strings.write_byte(&builder, ' ')
|
strings.write_byte(&builder, ' ')
|
||||||
}
|
}
|
||||||
j := 0
|
j := 0
|
||||||
|
if strings.contains_any(arg, "()[]{}^=;!'+,`~\" ") {
|
||||||
strings.write_byte(&builder, '"')
|
strings.write_byte(&builder, '"')
|
||||||
for j < len(arg) {
|
for j < len(arg) {
|
||||||
backslashes := 0
|
backslashes := 0
|
||||||
@@ -662,7 +663,7 @@ _build_command_line :: proc(command: []string, allocator: runtime.Allocator) ->
|
|||||||
break
|
break
|
||||||
} else if arg[j] == '"' {
|
} else if arg[j] == '"' {
|
||||||
_write_byte_n_times(&builder, '\\', 2*backslashes+1)
|
_write_byte_n_times(&builder, '\\', 2*backslashes+1)
|
||||||
strings.write_byte(&builder, '"')
|
strings.write_byte(&builder, arg[j])
|
||||||
} else {
|
} else {
|
||||||
_write_byte_n_times(&builder, '\\', backslashes)
|
_write_byte_n_times(&builder, '\\', backslashes)
|
||||||
strings.write_byte(&builder, arg[j])
|
strings.write_byte(&builder, arg[j])
|
||||||
@@ -670,6 +671,9 @@ _build_command_line :: proc(command: []string, allocator: runtime.Allocator) ->
|
|||||||
j += 1
|
j += 1
|
||||||
}
|
}
|
||||||
strings.write_byte(&builder, '"')
|
strings.write_byte(&builder, '"')
|
||||||
|
} else {
|
||||||
|
strings.write_string(&builder, arg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return strings.to_string(builder)
|
return strings.to_string(builder)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user