From: Eric Pouech <epouech(a)codeweavers.com> Mainly shows that upon batch invocation return from another batch file, i echo mode is kept; whereas, from command line, the echo mode is always reset to ON. Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- programs/cmd/tests/test_builtins.cmd | 50 ++++++++++++++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 7 ++++ 2 files changed, 57 insertions(+) diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 8552d51930a..01eef4fd7de 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -84,6 +84,56 @@ type mixedEchoModes.cmd cmd /c mixedEchoModes.cmd del mixedEchoModes.cmd +echo ------------ Testing call and echo modes ------------ +rem echo on/off is propagated back to caller (except in interactive mode) +(a)echo off +(a)FOR /F "tokens=* usebackq" %%F IN (`echo`) DO SET "wine_echo_on=%%F" +goto :hopCallEchoModes + +rem ensure comparison isn't locale dependant +:showEchoMode +(a)FOR /F "tokens=*" %%F IN (%1) DO @IF "%%F"=="%wine_echo_on%" (@echo ECHO_IS_ON) else (@echo ECHO_IS_OFF) +(a)del %1 +(a)exit /b 0 +:hopCallEchoModes + +echo %%*> callme.cmd +rem ensure that :showEchoMode works as expected +(a)echo on +(a)echo>foo.tmp +(a)call :showEchoMode foo.tmp +(a)echo off +(a)echo>foo.tmp +(a)call :showEchoMode foo.tmp +rem test inside a batch file, that caller keeps callee echo on/off status +(a)echo off +(a)call callme.cmd @echo on +(a)echo>foo.tmp +(a)call :showEchoMode foo.tmp +(a)echo on +(a)call callme.cmd @echo off +(a)echo>foo.tmp +(a)call :showEchoMode foo.tmp +(a)echo off + +rem test in interactive mode... echo is always preserved after a call +(a)echo echo on>foo.txt +(a)echo call callme.cmd @echo off>>foo.txt +(a)echo echo^>foo.tmp>>foo.txt +type foo.txt | cmd.exe > NULL +(a)call :showEchoMode foo.tmp + +(a)echo echo off>foo.txt +(a)echo call callme.cmd @echo on>>foo.txt +(a)echo echo^>foo.tmp>>foo.txt +type foo.txt | cmd.exe > NULL +(a)call :showEchoMode foo.tmp + +rem cleanup +del foo.txt +del callme.cmd +set wine_echo_on= +(a)echo off echo ------------ Testing parameterization ------------ call :TestParm a b c call :TestParm "a b c" diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 292c24985e8..0acdca096e3 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -142,6 +142,13 @@ foo bar foo2 bar2 +------------ Testing call and echo modes ------------ +ECHO_IS_ON +ECHO_IS_OFF +ECHO_IS_ON +ECHO_IS_OFF +(a)todo_wine@ECHO_IS_ON +(a)todo_wine@ECHO_IS_OFF ------------ Testing parameterization ------------ 'a', 'b', 'c' '"a b c"', '', '' -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7301