diff options
Diffstat (limited to 'zen/process_exec.cpp')
-rw-r--r-- | zen/process_exec.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/zen/process_exec.cpp b/zen/process_exec.cpp index a2c02eb0..ffc90b4f 100644 --- a/zen/process_exec.cpp +++ b/zen/process_exec.cpp @@ -21,19 +21,20 @@ Zstring zen::escapeCommandArg(const Zstring& arg) { //*INDENT-OFF* if not put exactly here, Astyle will seriously mess this .cpp file up! Zstring output; - for (const Zchar c : arg) + for (const char c : arg) switch (c) { + //case ' ': output += "\\ "; break; -> maybe nicer to use quotes instead? case '"': output += "\\\""; break; //Windows: not needed; " cannot be used as file name case '\\': output += "\\\\"; break; //Windows: path separator! => don't escape case '`': output += "\\`"; break; //yes, used in some paths => Windows: no escaping required default: output += c; break; } -//*INDENT-ON* - if (contains(output, Zstr(' '))) - output = Zstr('"') + output + Zstr('"'); //Windows: escaping a single blank instead would not work + if (contains(arg, ' ')) + output = '"' + output + '"'; //caveat: single-quotes not working on macOS if string contains escaped chars! no such issue on Linux return output; +//*INDENT-ON* } |