Fix Windows launcher issue
parent
f1bacc2110
commit
562ccb24f3
|
@ -0,0 +1,10 @@
|
|||
IN: io.windows.launcher.tests
|
||||
USING: tools.test io.windows.launcher ;
|
||||
|
||||
[ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test
|
||||
|
||||
[ "bob \"mac arthur\"" ] [ { "bob" "mac arthur" } join-arguments ] unit-test
|
||||
|
||||
[ "bob mac\\\\arthur" ] [ { "bob" "mac\\\\arthur" } join-arguments ] unit-test
|
||||
|
||||
[ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test
|
|
@ -44,8 +44,21 @@ TUPLE: CreateProcess-args
|
|||
lpProcessInformation>>
|
||||
} get-slots CreateProcess win32-error=0/f ;
|
||||
|
||||
: count-trailing-backslashes ( str n -- str n )
|
||||
>r "\\" ?tail [
|
||||
r> 1+ count-trailing-backslashes
|
||||
] [
|
||||
r>
|
||||
] if ;
|
||||
|
||||
: fix-trailing-backslashes ( str -- str' )
|
||||
0 count-trailing-backslashes
|
||||
2 * CHAR: \\ <repetition> append ;
|
||||
|
||||
: escape-argument ( str -- newstr )
|
||||
CHAR: \s over member? [ "\"" swap "\"" 3append ] when ;
|
||||
CHAR: \s over member? [
|
||||
"\"" swap fix-trailing-backslashes "\"" 3append
|
||||
] when ;
|
||||
|
||||
: join-arguments ( args -- cmd-line )
|
||||
[ escape-argument ] map " " join ;
|
||||
|
|
Loading…
Reference in New Issue