Different echo?...
variants
#22
Replies: 1 comment
-
That is an excellent summary of the Windows command echo and which character to use as separator between the command and the text to output. There could be added to section Interesting is the behavior of Example: A batch file named
There is in the current working directory a subdirectory with the name
The execution of Conclusion: There should never be used |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is different
echo?...
variants to call with pros and cons from a script.Note
The following results may vary behind other aspects like:
cmd.exe
, like clink, TCC, etc.PATH
variable existence or it's altered (not default) value.Note
The
cmd.exe
may skip query a path from thePATH
variable if it begins by the%SystemRoot%
as a raw prefix. So you have to alter thePATH
variable to trigger thecmd.exe
query logic.Note
To reset the environment variables to a default state you can use reset-env.bat script.
Note
To trigger the
cmd.exe
to query thePATH
variable you can evaluate thePATH
variable:call set PATH=%PATH%
echo <text>
orecho<tab><text>
Pros:
PATH
variable or current directory to open theecho <text>
file.Cons:
<text>
must be not empty, otherwiseECHO is on.
will be printed. So it can not print empty string.<text>
must not start by/?
, otherwise the usage help will be printed.echo;<text>
orecho,<text>
orecho=<text>
Note
The
;
,,
,=
characters treated as separator characters and replaced by a space character in a batch script command line.Pros:
PATH
variable or current directory to open theecho <text>
file.Cons:
<text>
must not start by/?
, otherwise the usage help will be printed.echo.<text>
Pros:
/?
as is.Cons:
PATH
(includingPATHEXT
) variable to open theecho.<text>
file.echo:<text>
Pros:
/?
as is.PATH
variable to open theecho:<text>
file.Cons:
echo:<text>
file (does not exist).echo/<text>
Pros:
/?
as is.PATH
variable to open theecho/<text>
file (not a valid file or path).Cons:
<text>
must not start by?
, otherwise the usage help will be printed.echo\<text>
Pros:
/?
as is.PATH
variable to open theecho\<text>
file.Cons:
echo\<text>
path (can exist), but does nothing.echo+<text>
Pros:
/?
as is.Cons:
PATH
(includingPATHEXT
) variable to open theecho+<text>
file.echo(<text>
Pros:
/?
as is.PATH
variable to open theecho(<text>
file.Cons:
for
variable context. See issues.Bench tests:
https://github.com/andry81/contools/tree/HEAD/Scripts/Tests/bench/batscripts
Issues:
echo(
does not evaluate infor
variable context:Result:
Beta Was this translation helpful? Give feedback.
All reactions