Jason Edmeades : cmd: for /f fails to launch quoted program plus args.

Alexandre Julliard julliard at winehq.org
Thu Nov 29 15:09:37 CST 2018

Module: wine
Branch: stable
Commit: c7bbcd46ad8eb8a3a35858a5f0883f3687e08922
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c7bbcd46ad8eb8a3a35858a5f0883f3687e08922

Author: Jason Edmeades <us at edmeades.me.uk>
Date:   Mon Aug 27 20:41:51 2018 +0100

cmd: for /f fails to launch quoted program plus args.

for /f can run a program and parse its output. The program name can
supply args and be quoted or not.  If quoted, wine fails to run the
program because internally we were adding an extra pair of
quotes. These are not needed and can be removed.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39906
Signed-off-by: Jason Edmeades <us at edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 8b6ba774c0ef5f25e1dfd314d870b16f60dce2b6)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>


 programs/cmd/builtins.c                  | 2 +-
 programs/cmd/tests/test_builtins.cmd     | 4 +++-
 programs/cmd/tests/test_builtins.cmd.exp | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 160940e..5d1e1b6 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2065,7 +2065,7 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd
   static const WCHAR redirOutW[]  = {'>','%','s','\0'};
   static const WCHAR cmdW[]       = {'C','M','D','\0'};
   static const WCHAR cmdslashcW[] = {'C','M','D','.','E','X','E',' ',
-                                     '/','C',' ','"','%','s','"','\0'};
+                                     '/','C',' ','%','s','\0'};
   /* Remove leading and trailing character */
   if ((iscmd && (itemstr[0] == '`' && usebackq)) ||
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 03c6cc8..dcc4eb7 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1672,9 +1672,11 @@ if "%CD%"=="" goto :SkipFORFcmdNT4
 for /f %%i in ('echo.Passed1') do echo %%i
 for /f "usebackq" %%i in (`echo.Passed2`) do echo %%i
 for /f usebackq %%i in (`echo.Passed3`) do echo %%i
+for /f "usebackq" %%i in (`"c:\windows\system32\cmd.exe" /C echo Passed4`) do echo %%i
+for /f "usebackq" %%i in (`""c:\windows\system32\cmd.exe" /C echo Passed5"`) do echo %%i
 goto :ContinueFORF
-for /l %%i in (1,1,3) do echo Missing functionality - Broken%%i
+for /l %%i in (1,1,5) do echo Missing functionality - Broken%%i
 rem FIXME: Rest not testable right now in wine: not implemented and would need
 rem preliminary grep-like program implementation (e.g. like findstr or fc) even
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 0431e41..78cbcf1 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1198,6 +1198,8 @@ c
 Passed1 at or_broken@Missing functionality - Broken1
 Passed2 at or_broken@Missing functionality - Broken2
 Passed3 at or_broken@Missing functionality - Broken3
+Passed4 at or_broken@Missing functionality - Broken4
+Passed5 at or_broken@Missing functionality - Broken5
 ------ eol option
 and at or_broken@Broken NT4 functionality1
 Line at or_broken@Broken NT4 functionality2

More information about the wine-cvs mailing list