From: Alexander Merkle alexander.merkle@lauterbach.com
as discussed in https://gitlab.winehq.org/wine/wine/-/merge_requests/277
Signed-off-by: Alexander Merkle alexander.merkle@lauterbach.com --- programs/cmd/tests/test_builtins.cmd | 13 +++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 3 +++ programs/cmd/wcmdmain.c | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 35caf136e4c..d72fcf2385a 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1043,6 +1043,19 @@ if 1 == 0 ( @tab@ @space@ ) else echo block containing a line with just spaces seems to work +echo --- if with unbalanced parentheses +echo @echo off>block_if_eof1.cmd +echo echo sanity1>>block_if_eof1.cmd +echo if 1 == 1 (>>block_if_eof1.cmd +echo echo should not be executed>>block_if_eof1.cmd +call block_if_eof1.cmd +del block_if_eof1.cmd +echo @echo off>block_if_eof2.cmd +echo echo sanity2>>block_if_eof2.cmd +echo if 1 == 0 (>>block_if_eof2.cmd +echo echo should not be executed>>block_if_eof2.cmd +call block_if_eof2.cmd +del block_if_eof2.cmd echo --- case sensitivity with and without /i option if bar==BAR echo if does not default to case sensitivity if not bar==BAR echo if seems to default to case sensitivity diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 379225f38e5..145f97a550a 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -710,6 +710,9 @@ windir does exist block containing a line with just spaces seems to work block containing a line with just spaces seems to work block containing a line with just spaces seems to work +--- if with unbalanced parentheses +sanity1 +sanity2 --- case sensitivity with and without /i option if seems to default to case sensitivity if /i seems to work diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 5d5c18eacb6..473ead28ab9 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -2312,8 +2312,10 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE do { WINE_TRACE("Read more input\n"); if (!context) WCMD_output_asis( WCMD_LoadMessage(WCMD_MOREPROMPT)); - if (!WCMD_fgets(extraData, MAXSTRING, readFrom)) - break; + if (!WCMD_fgets(extraData, MAXSTRING, readFrom)) { + /* EOF in parentheses - abort don't execute block */ + return NULL; + }
/* Edge case for carets - a completely blank line (i.e. was just CRLF) is oddly added as an LF but then more data is received (but