Commit a45301cb authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd: Strip quotes from for /f string before attempting to parse it.

parent 182c5459
......@@ -2086,8 +2086,18 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
} else if (doFileset && ((!forf_usebackq && *itemStart == '"') ||
(forf_usebackq && *itemStart == '\''))) {
/* Remove leading and trailing character, ready to parse with delims= delimiters
Note that the last quote is removed from the set and the string terminates
there to mimic windows */
WCHAR *strend = strrchrW(itemStart, forf_usebackq?'\'':'"');
if (strend) {
*strend = 0x00;
itemStart++;
}
/* Copy the item away from the global buffer used by WCMD_parameter */
strcpyW(buffer, item);
strcpyW(buffer, itemStart);
WCMD_parse_line(cmdStart, firstCmd, &cmdEnd, variable, buffer, &doExecuted,
&forf_skip, forf_eol);
......
......@@ -1111,11 +1111,22 @@ set var=
echo --- for /F
mkdir foobar & cd foobar
echo ------ string argument
rem NT4 does not support usebackq
for /F %%i in ("a b c") do echo %%i
for /f usebackq %%i in ('a b c') do echo %%i>output_file
if not exist output_file (echo no output) else (type output_file & del output_file)
for /f %%i in ("a ") do echo %%i
for /f usebackq %%i in ('a ') do echo %%i>output_file
if not exist output_file (echo no output) else (type output_file & del output_file)
for /f %%i in ("a") do echo %%i
for /f usebackq %%i in ('a') do echo %%i>output_file
if not exist output_file (echo no output) else (type output_file & del output_file)
fOr /f %%i in (" a") do echo %%i
for /f usebackq %%i in (' a') do echo %%i>output_file
if not exist output_file (echo no output) else (type output_file & del output_file)
for /f %%i in (" a ") do echo %%i
for /f usebackq %%i in (' a ') do echo %%i>output_file
if not exist output_file (echo no output) else (type output_file & del output_file)
echo ------ fileset argument
echo --------- basic blank handling
echo a b c>foo
......
......@@ -781,11 +781,16 @@ ErrorLevel 0
--- for /F
------ string argument
@todo_wine@a
@todo_wine@a
a
@todo_wine@a
@todo_wine@a
a@or_broken@no output
a
a@or_broken@no output
a
a@or_broken@no output
a
a@or_broken@no output
a
a@or_broken@no output
------ fileset argument
--------- basic blank handling
a
......@@ -817,18 +822,18 @@ Passed3@or_broken@Missing functionality - Broken3
and@or_broken@Broken NT4 functionality1
Line@or_broken@Broken NT4 functionality2
Line@or_broken@Broken NT4 functionality3
@todo_wine@ad
@todo_wine@z@y
ad
z@y
a|d
@todo_wine@no output
no output
@todo_wine@no output
------ delims option
@todo_wine@a
@todo_wine@a@space@
@todo_wine@a d
@todo_wine@a
a
@todo_wine@C r
foo bar baz
@todo_wine@foo bar baz
@todo_wine@c:\
------ skip option
c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment