4

What function does the open parenthesis serve in this command?

Why is there no closed parenthesis?

>> datatest.csv.TEMP echo(!modified!
0

1 Answer 1

8

This is the result of a discussion on DosTips about nine years ago.

Your code will redirect the value of !modified! to datatest.csv.TEMP or it will print a blank line in that file if the variable is empty. According to echo /?, the official way to display a blank line is to use echo.. However, if cmd.exe is somehow able to find an executable with no extension called echo (for example, a file in the same directory as the script), that file gets used instead of the regular echo command.

A few alternatives to echo. were considered, including echo\, echo:, echo/ and echo(. echo\ was ruled out in case of a situation where there was a folder called echo that contained a file with the same name as whatever was being echoed. echo/ was ruled out in situations where the string to be displayed started with a ?, because in the case the help was displayed. echo: was ruled out for extremely rare situations where string substitution was being utilized.

Ultimately, echo( was ended up with simply because nobody could find a situation where it didn't work. (Later on, there was some speculation that echo=, echo,, and echo; are all safe to use without weird side effects or edge cases. However, if you are trying to display the literal string /?, the help for echo will be displayed instead.)

The ) is not included because it will get displayed.

3
  • 2
    echo=, echo; and echo, all fail, when !modified! expands to /?. Then the help of the echo command is displayed
    – jeb
    Commented Dec 27, 2018 at 9:32
  • Thank you both for your notes; my answer had been updated accordingly. Commented Dec 27, 2018 at 13:50
  • 1
    I always preferred the colon because the ( irritates users as this question proves. (+1)
    – user6811411
    Commented Dec 27, 2018 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.