On Windows, escape command line arguments with double quotes with a backslash: " -> \". Fixes #245.

db4
Doug Coleman 2011-10-10 22:22:09 -07:00
parent 84fda0bb05
commit 871dfb9a3a
2 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,12 @@ IN: io.launcher.windows.tests
[ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test
! Bug #245
[ "\\\"hi\\\"" ] [ { "\"hi\"" } join-arguments ] unit-test
[ "\"\\\"hi you\\\"\"" ] [ { "\"hi you\"" } join-arguments ] unit-test
[ ] [
<process>
"notepad" >>command

View File

@ -58,7 +58,11 @@ TUPLE: CreateProcess-args
0 count-trailing-backslashes
2 * CHAR: \\ <repetition> append ;
: escape-double-quote ( str -- newstr )
"\"" split "\\\"" join ;
: escape-argument ( str -- newstr )
escape-double-quote
CHAR: \s over member? [
fix-trailing-backslashes "\"" dup surround
] when ;