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

cmd: Handle unechoed rem commands inside a (..) section.

When processing a (..) multiline section, each line is processed and if it starts with a '@' it is not echoed, but more importantly if is 'rem' then anything else on that line should be ignored. The reported issue was that a pipe was being executed when it was hidden behind a rem, which was trigged by the preceeding '@' character not being skipped. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45729Signed-off-by: 's avatarJason Edmeades <us@edmeades.me.uk> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 1a7333be
......@@ -1427,6 +1427,12 @@ for /L %%i in (2,2,1) do (
echo %%i
echo FAILED
)
echo --- rems inside for loops
for /f %%i IN ("hello") DO (
REM foo|echo ERROR unexpected execution 1
@REM foo|echo ERROR unexpected execution 2
@ REM foo|echo ERROR unexpected execution 3
)
echo --- ifs inside for loops
for %%i in (test) do (
echo a1
......
......@@ -996,6 +996,7 @@ ErrorLevel 0
-1
1
3
--- rems inside for loops
--- ifs inside for loops
a1
b1
......
......@@ -2308,12 +2308,21 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
} while (*extraData == 0x00);
curPos = extraSpace;
if (context) handleExpansion(extraSpace, FALSE, FALSE);
/* Skip preceding whitespace */
while (*curPos == ' ' || *curPos == '\t') curPos++;
/* Replace env vars if in a batch context */
if (context) handleExpansion(curPos, FALSE, FALSE);
/* Continue to echo commands IF echo is on and in batch program */
if (context && echo_mode && extraSpace[0] && (extraSpace[0] != '@')) {
if (context && echo_mode && *curPos && *curPos != '@') {
WCMD_output_asis(extraSpace);
WCMD_output_asis(newlineW);
}
/* Skip repeated 'no echo' characters and whitespace */
while (*curPos == '@' || *curPos == ' ' || *curPos == '\t') curPos++;
}
}
......
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