Merge pull request #4272 from flysand7/os2-noquote

[os2/process]: Don't quote arguments unless needed
This commit is contained in:
Laytan
2024-10-04 23:12:07 +02:00
committed by GitHub
+5 -1
View File
@@ -650,6 +650,7 @@ _build_command_line :: proc(command: []string, allocator: runtime.Allocator) ->
strings.write_byte(&builder, ' ')
}
j := 0
if strings.contains_any(arg, "()[]{}^=;!'+,`~\" ") {
strings.write_byte(&builder, '"')
for j < len(arg) {
backslashes := 0
@@ -662,7 +663,7 @@ _build_command_line :: proc(command: []string, allocator: runtime.Allocator) ->
break
} else if arg[j] == '"' {
_write_byte_n_times(&builder, '\\', 2*backslashes+1)
strings.write_byte(&builder, '"')
strings.write_byte(&builder, arg[j])
} else {
_write_byte_n_times(&builder, '\\', backslashes)
strings.write_byte(&builder, arg[j])
@@ -670,6 +671,9 @@ _build_command_line :: proc(command: []string, allocator: runtime.Allocator) ->
j += 1
}
strings.write_byte(&builder, '"')
} else {
strings.write_string(&builder, arg)
}
}
return strings.to_string(builder)
}