I couldn't find anything but is there any reason for choosing
$ like in *nix shells?
By using a
\ as path separator, they needed a different marker for control character encoding, and did choose
$ which in turn meant that the variable marker need to be another one, which turned out as
So by choosing
% instead they could have kept
$ for variables, but then again is the parser structured a bit different as it allows concatenated strings, thus needing a finishing marker at the end of named variables. So they didn't and the rest is history :))
I'm not complete so sure right now about the full implications, but
$ is used at least in three different ways on the MS-DOS command line and in batch.
- Expand a batch variable to a full path name with
- Defining special content for the PROMPT command like date and time as in
prompt $d $t$g.
- Code the escape character in parameters as
echo $e[0mfor screen reset.
Especially the does give the lead here, as marking special characters in Unix is done via a backslash
\, which in DOS marks a directory level. MS had to use
$ instead, so
Further, but way later (DOS 5)
- DOSKEY used
$to indicate special functions in macro generation.
Surprisingly, its predecessor CP/M did use
$ as variable indicator as well as marker for special meanings in some commands (like privileges in
In CP/M batch files are run with the
SUBMIT command, which will read a file (standard ending
.SUB) and feed each line to the OS, after replacing variables marked with
$. DOS has this feature build in and treats
.BAT files like programs.