From 871dfb9a3ab3a7f4d2420bdad85c66c55e487c1a Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 10 Oct 2011 22:22:09 -0700 Subject: [PATCH] On Windows, escape command line arguments with double quotes with a backslash: " -> \". Fixes #245. --- basis/io/launcher/windows/windows-tests.factor | 6 ++++++ basis/io/launcher/windows/windows.factor | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/basis/io/launcher/windows/windows-tests.factor b/basis/io/launcher/windows/windows-tests.factor index d040edb302..3d3d29a937 100644 --- a/basis/io/launcher/windows/windows-tests.factor +++ b/basis/io/launcher/windows/windows-tests.factor @@ -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 + + [ ] [ "notepad" >>command diff --git a/basis/io/launcher/windows/windows.factor b/basis/io/launcher/windows/windows.factor index 47aeb0c712..100f2d36ff 100755 --- a/basis/io/launcher/windows/windows.factor +++ b/basis/io/launcher/windows/windows.factor @@ -58,7 +58,11 @@ TUPLE: CreateProcess-args 0 count-trailing-backslashes 2 * CHAR: \\ 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 ;