From: Alex Henrie alexhenrie24@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55124 --- programs/cmd/tests/test_builtins.cmd | 9 +++++++++ programs/cmd/tests/test_builtins.cmd.exp | 6 ++++++ programs/cmd/wcmdmain.c | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index eaee2900bc9..0cb05041fa9 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -176,6 +176,15 @@ del foo echo foo> foo echo foo7 7>> foo || (echo not supported & del foo) if exist foo (type foo) else echo not supported +echo --- redirect at beginning of line +>foo (echo foo) +type foo +1>foo (echo foo1) +type foo +2>foo (echo foo2 >&2) +type foo +>>foo (echo fooA) +type foo echo --- redirections within IF statements if 1==1 echo foo1>bar type bar & del bar diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 411eae303ac..b28c6709d57 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -204,6 +204,12 @@ food2 food21 @todo_wine@foo7@space@@space@@or_broken@not supported@space@ @todo_wine@foo@or_broken@not supported +--- redirect at beginning of line +foo +foo1 +foo2 +foo2 +fooA --- redirections within IF statements foo1 foo2 diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index de6e721b26a..298606f6caa 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -2070,9 +2070,9 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE /* See if 1>, 2> etc, in which case we have some patching up to do (provided there's a preceding whitespace, and enough chars read so far) */ - if (curStringLen > 2 - && (*(curPos-1)>='1') && (*(curPos-1)<='9') - && ((*(curPos-2)==' ') || (*(curPos-2)=='\t'))) { + if (curPos[-1] >= '1' && curPos[-1] <= '9' + && (curStringLen == 1 || + curPos[-2] == ' ' || curPos[-2] == '\t')) { curStringLen--; curString[curStringLen] = 0x00; curCopyTo[(*curLen)++] = *(curPos-1);