Roman Terekhov said the following on 23.06.2008 14:03:
I like to write batch scripts to execute several git commands at
the same time. Now the @echo off (in the first line of the git.cmd)
disables echo, so that I am not able to see which command are
executing (except for the very first one :-)

With other words, now the git.cmd batch performs two distinct
tasks: - execute git.exe in the proper way - disables echo (while
ideally it should preserve the echo state that was before git.cmd
execution)

The last task does not look to be natural for the git.cmd at all. I
don't know how to preserve the original echo state (after git.cmd execution), but if git.cmd switch off echo at the start, it should
switch it on back at the end. It is just my personal meaning of
course, and nothing more.

I'd like to argue that most scripts on Windows normally turns off echo as the first thing they do. If that holds true, shouldn't it then rather be *your* job to ensure that *your* script works the way *you* intended it to, independently of what others do?

I mean, it's really not that hard. Try this, for example:
    @SETLOCAL
    @ECHO | c:\WINDOWS\system32\find.exe "ECHO is off." >NUL
    @SET EchoWasOff=%ERRORLEVEL%
    @ECHO on

    ECHO Do stuff youd like echoed here

    @REM Turn off echo again, if caller liked that
    @IF "%EchoWasOff%" EQU "1" ECHO off

If you use that as your boilerplate for BAT scripts, you should always get what you want..

--
.marius

Reply via email to