Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55662
Tests are not provided as its interactive.
-- v12: cmd: Do not set enviroment variable when no input is provided by set /p command.
From: Vijay Kiran Kamuju infyquest@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55662 --- programs/cmd/builtins.c | 14 +++++++++++--- programs/cmd/tests/test_builtins.cmd | 5 +++++ programs/cmd/tests/test_builtins.cmd.exp | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 17671c32eba..0ae382ff3a8 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3188,7 +3188,7 @@ RETURN_CODE WCMD_setshow_env(WCHAR *s) }
/* If no parameter, or no '=' sign, return an error */ - if (!(*s) || ((p = wcschr (s, '=')) == NULL )) { + if (!(*s) || ((p = wcschr(s, '=')) == NULL )) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG)); return_code = ERROR_INVALID_FUNCTION; } @@ -3196,7 +3196,15 @@ RETURN_CODE WCMD_setshow_env(WCHAR *s) { /* Output the prompt */ *p++ = '\0'; - if (*p) WCMD_output_asis(p); + if (*p) { + p = WCMD_strtrim(p); + if (*p == L'"') { + WCHAR* last = wcsrchr(p+1, L'"'); + p++; + if (last) *last = L'\0'; + } + WCMD_output_asis(p); + }
/* Read the reply */ if (WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count) && count > 1) { @@ -3204,7 +3212,7 @@ RETURN_CODE WCMD_setshow_env(WCHAR *s) if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */ TRACE("set /p: Setting var '%s' to '%s'\n", wine_dbgstr_w(s), wine_dbgstr_w(string)); - SetEnvironmentVariableW(s, string); + if (*string) SetEnvironmentVariableW(s, string); } }
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index c67fc84988a..53d3ceb0444 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -835,6 +835,11 @@ del folder\sub1.bat rmdir "fol;der" rmdir folder PATH=%PATH_BACKUP% +set WINE_FOO=foo +echo bar| cmd /v:on /c "set /p WINE_FOO=prompt & echo X!WINE_FOO!X" +echo:| cmd /v:on /c "set /p WINE_FOO=prompt & echo Y!WINE_FOO!Y" +echo:| cmd /v:on /c "set /p WINE_FOO='prompt' & echo Y!WINE_FOO!Y" +echo:| cmd /v:on /c "set /p WINE_FOO="prompt" & echo Y!WINE_FOO!Y"
echo ------------ Testing 'choice' ------------
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 84bcdcdf581..96e2500f48c 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -689,6 +689,10 @@ foo I'm here!@space@ I'm here!@space@ I'm here!@space@ +prompt XbarX +prompt YfooY +'prompt' YfooY +@todo_wine@promptYfooY ------------ Testing 'choice' ------------ @todo_wine@Example message [A,B,C]?A@or_broken@choice unavailable 1@or_broken@9009
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147043
Your paranoid android.
=== debian11 (32 bit report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit ar:MA report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit de report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit fr report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit he:IL report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit hi:IN report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit ja:JP report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11 (32 bit zh:CN report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11b (32 bit WoW report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
=== debian11b (64 bit WoW report) ===
cmd.exe: batch.c:331: Test failed: unexpected char 0x58 position 6 in line 692 (got 'promptXbarX', wanted 'prompt XbarX') batch.c:331: Test failed: unexpected char 0x59 position 6 in line 693 (got 'promptYfooY', wanted 'prompt YfooY') batch.c:331: Test failed: unexpected char 0x59 position 8 in line 694 (got ''prompt'YfooY', wanted ''prompt' YfooY') batch.c:331: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 695 (got 'promptYfooY', wanted 'promptYfooY')
ddraw: ddraw1.c:3645: Test failed: Expected (0,0)-(640,480), got (-32000,-32000)-(-31840,-31969).
user32: input.c:5027: Test failed: 2:2: expected that X keystate is set input.c:5027: Test failed: 2:2: expected that X keystate is set input.c:5028: Test failed: 2:2: expected that X highest bit is set, got 0 input.c:5029: Test failed: 2:2: expected that X keystate is set input.c:5029: Test failed: 2:2: expected that X keystate is set input.c:4941: Test failed: 2:2: expected that X highest bit is set, got 0x1 input.c:4942: Test failed: 2:2: expected that X keystate is set input.c:4942: Test failed: 2:2: expected that X keystate is set input.c:5045: Test failed: 2:2: expected that X keystate is set input.c:5045: Test failed: 2:2: expected that X keystate is set input.c:5046: Test failed: 2:2: expected that X highest bit is set, got 0 input.c:5047: Test failed: 2:2: expected that X keystate is set input.c:5047: Test failed: 2:2: expected that X keystate is set input.c:4949: Test failed: 2:2: expected that X keystate is set input.c:4949: Test failed: 2:2: expected that X keystate is set
looks good to me. Thanks. Note: it looks like the overall handling of quotes in SET command will need some more work (even without /P option), but that's a separated issue.