Roman Terekhov said the following on 24.06.2008 09:38:
I'd like to argue that most scripts on Windows normally turns off
echo as the first thing they do. I did not know about it. If it is
normal to turn off echo, let it be the way it coded now. I can fix
git.cmd on my own PC.
The script example you send does not help, because after each call
to git.cmd echo is disabled. The solution can be to execute @echo
on after each git.cmd, but I am not shore whether it is the right
way to code. It should be so if "most scripts on Windows normally
turns off echo as the first thing they do".
The code I provided was for you to use as a boilerplate for your
scripts. The script detects if echo was on or off when the script was
invoked, turns ON echo (which is what you wanted), then turns echo
back to the state it was when the script was executed.
> @ECHO | c:\WINDOWS\system32\find.exe "ECHO is off." >NUL
> @SET EchoWasOff=%ERRORLEVEL%
As I understood, these lines should find out the state echo (whether it
is ON or OFF).
But I always get EchoWasOff = '1' :-(
Grrr, I knew I should have tested it before sending it. Turns out that
piping ECHO alters detection, so it always returns one value. That
means you have to do an indirection to get the result:
@SETLOCAL
@SET TESTRAND=%RANDOM%
@ECHO > %TEMP%\echotest%TESTRAND%.txt
@FIND "on" %TEMP%\echotest%TESTRAND%.txt >NUL
@SET EchoWasOff=%ERRORLEVEL%
@DEL %TEMP%\echotest%TESTRAND%.txt
@ECHO on
ECHO Replace this with your own commands which youd like echoed
@REM Turn off echo again, if caller liked that
@IF "%EchoWasOff%" EQU "1" ECHO off
--
.marius