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