The $ character and VMS
Sometimes I get asked or see a question in my web server,
"why in VMS so many names of files or variables contain the '$' character ?".
Well in principle, "$" has no significance, and is just a character in names
, except in 2 cases:
1. Leading $ in DCL command-files
In a DCL command-file (the VMS "shell" script language),
if the first character in a line is a "$", then the line is interpreted
as a command (or DCL statement).
Lines not starting with a "$" are considered to be input data to the command
(or program invocation) preceding the line.
The first line starting again with "$" ends the input to the command,
except in a block started with the "$DECK" statement,
which ends with an "$EOD", and can contain "$" line within the block.
For details see DCL command "HELP DECK" in VMS.
2. Leading $ in DCL symbols
A DCL symbol defining a foreign command signals with a leading "$"
that the filename following is the name of an executable file to be invoked
with this command name. A missing "$" in this case means the symbol is an
alias for the command following.
"$" is a character "reserved to Digital"
In all other circumstances, "$" is a character "reserved to Digital". In this
case it means: "$" in (file-,symbol-,logical ,variable-)names should only be
used by VMS system- or application-facilities, not by user programs and
procedures.
All system directories,symbols and logical names,
and many file-names contain the "$", mostly in the form facility$name.
If one follows the rules, then there will be no name clash with user programs.
The same rule applies for procedure- and variable-names in compiled or
interpreted languages.
In DECC (Compaq C, HP C), use of "$" is a language extension for VMS, to enable
system- and run-time-libraries to keep the VMS facility$name convention.
Here also use of "$" must be avoided by application code.
"$" clashes with variable substitution in Unix type shells
If one is transferring files between VMS and Unix type systems, one has to
escape the "$" in file-names by using "\$", because the Unix shells interpret
"$" as the variable substitution operator.
This applies as well for Unix shells used in VMS, like the GNV bash shell.
Example: If one defines the "ls" command as "ls := bash -c "ls",
then "ls /sys$manager" will fail to list the sys$manager: directory,
but "ls /sys\$manager" will succeed.