In my experience, just about every single MS-DOS (and thus Windows cmd
) batch file starts with the line @echo off
, to silently switch off echoing of the commands in the batch file to the console. This seems unnecessarily noisy, and raises the title question: why not have echo
default to off
within batch scripts?
I've searched around a bit, but haven't come across anything that's directly shed light on this. It seems likely that this answer touches on some of the factors leading to this decision, but by my read doesn't answer this question directly.
The one thing I can think of emerges as a consequence of the following snip from the Microsoft docs:
- After echo is turned off, the command prompt doesn't appear in the Command Prompt window. To display the command prompt, type echo on.
I could see it being the case that the early MS-DOS interpreters didn't have any particular way of determining the scope of the commands they were executing; in other words, they couldn't tell whether they were running directly-typed console commands or commands from a batch file, and thus the echo
setting was effectively (or actually) global. Thus, since most of the time(?) users would want the prompt to be displayed at the console, echo on
became the sensible default....and, from there, perhaps Microsoft just grandfathered the echo on
default to retain backward compatibility? I have no idea if this actually had anything to do with it, though.