the problem:
If you want to echo a variable that could be empty you can not use
Code: Select all
echo %var%
because the output is not empty, instead you got "echo is enabled (on)" or something similar.
So most people use the echo. trick
Code: Select all
echo.%var%
This works, but fails if you have anywhere in your path a file named "echo".
Then you got an error (echo. could not be found ...)
As I wrote in the topic http://www.dostips.com/forum/viewtopic.php?f=3&t=1226
you can use instead
Code: Select all
echo\%var%
This works in the most situations.
But as I learned from aGerman's code, not in all situations.
Because if var begins with . you got the same error(echo. could not be found ...)
or with var=..\myCommand.bat it will start myCommand
So I try some other possibilities and found the (currently) best way.
Code: Select all
echo,%var%
or
echo;%var%
This seems to be bullet proof, and it is faster than the others, because the path will not be scanned for files.
On my system it is 15% faster than the echo. variant