command line parsing question

Jul 21, 2015
4
0
Germany
Hallo,
in a batch file I wanted to show some messages and found a strange behaviour in the output of an echo command. This echo command
echo At %_TIME: T=%_TRANSIENT
displayed
At 14:55:39_TRANSIENT
Without the colon after %_TIME I got the expected
At 14:57:38 T=0

What does the colon do in the echo?
BTW, entering a blank before : does also cure the effect.

This happens with TCC 15.00.33

- Heinz Saathoff
 
May 20, 2009
258
2
54
ITALY
Hallo,
in a batch file I wanted to show some messages and found a strange behaviour in the output of an echo command. This echo command
echo At %_TIME: T=%_TRANSIENT
displayed
At 14:55:39_TRANSIENT
Without the colon after %_TIME I got the expected
At 14:57:38 T=0

What does the colon do in the echo?
BTW, entering a blank before : does also cure the effect.

This happens with TCC 15.00.33

- Heinz Saathoff
I believe that You hit the syntax for text replacement.
At http://ss64.com/nt/syntax-replace.html You can find more information.

Regards

Rodolfo Giovanninetti
 

samintz

Scott Mintz
May 20, 2008
1,340
12
Solon, OH, USA
Yes. That is CMD.EXE's syntax for string substitution. You can work around it in TCC by enclosing the variable in []'s:
Code:
echo %[_TIME]: T=%_TRANSIENT