Thank you for the script, but in my scripts I just need to call @echo on
after each git command:

Example:
  call git remote add test ...
  @echo on
  call git fetch test
  @echo on
  call git branch test-master remotes/test/master
  @echo on
  call git checkout test-master
  @echo on

I don't need to detect the echo state in my scripts. I just know that
git.cmd turn echo off, so I can turn it on again.
Or I can fix git.cmd on my own PC (that is what I actually do).


On Tue, Jun 24, 2008 at 1:34 PM, Marius Storm-Olsen <[EMAIL PROTECTED]>
wrote:

> 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
>



-- 
Roman Terekhov



-- 
Roman Terekhov

Reply via email to