From: Vijay Kiran Kamuju infyquest@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55662 --- programs/cmd/builtins.c | 9 ++++++--- programs/cmd/tests/test_builtins.cmd | 18 +++++++++++++++--- programs/cmd/tests/test_builtins.cmd.exp | 7 ++++++- 3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 708e3c6dce6..0e943305d83 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3146,14 +3146,17 @@ void 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; }
/* Output the prompt */ *p++ = '\0'; - if (*p) WCMD_output_asis(p); + if (*p) { + if (wcschr(p, '"')) WCMD_strip_quotes(p); + WCMD_output_asis(p); + }
/* Read the reply */ if (WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count) && count > 1) { @@ -3161,7 +3164,7 @@ void WCMD_setshow_env (WCHAR *s) { if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */ WINE_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); }
/* See if /A supplied, and if so calculate the results of all the expressions */ diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index d31cb3ef72a..3810a7c01a6 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1727,8 +1727,8 @@ for %%i in (test) do ( ) echo d4 ) -echo --- set /a -goto :testseta +echo --- set +goto :testset
Rem Ideally for /f can be used rather than building a command to execute rem but that does not work on NT4 @@ -1747,9 +1747,21 @@ goto :checkenvvars %* goto :eof
-:testseta +:testset rem No output when using "set expr" syntax, unless in interactive mode rem Need to use "set envvar=expr" to use in a batch script +echo ------ interactive operations +set WINE_foo=test +echo wine> foo +set /p WINE_foo=prompt < NUL +call :checkenvvars WINE_foo test +set /p WINE_foo="prompt" < NUL +call :checkenvvars WINE_foo test +set /p WINE_foo='prompt' < NUL +call :checkenvvars WINE_foo test +set /p WINE_foo=prompt < foo +call :checkenvvars WINE_foo wine +del foo echo ------ individual operations set WINE_foo=0 set /a WINE_foo=1 +2 & call :checkenvvars WINE_foo 3 diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index c2dba03b740..27cf499260a 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1122,7 +1122,12 @@ d3 a4 c4 d4 ---- set /a +--- set +------ interactive operations +prompt WINE_foo correctly test +prompt WINE_foo correctly test +'prompt' WINE_foo correctly test +prompt WINE_foo correctly wine ------ individual operations WINE_foo correctly 3 WINE_foo correctly -1