Why was the dot (.) used as an alias for source & why don't other commands have shortcuts too?
.
is the POSIX standard.
source
is a bash builtin synonym for .
and is not as portable as .
Also note in the Bash reference manual .
is listed under 4.1 Bourne Shell Builtins and source
is listed under 4.2 Bash Builtin Commands as:
A synonym for . (see Bourne Shell Builtins).
It's possible that bash named it source
because that's what it was called in C shell (where the command apparently originated).
As far as Bash is concerned the .
and source
are not aliases for one or the other, it's a simple fact that they're both builtins which call the same underlying function, source_builtin
.
Take a look at the source.def
file from the Bash source code:
$PRODUCES source.c
$BUILTIN source
$FUNCTION source_builtin
$SHORT_DOC source filename [arguments]
Execute commands from a file in the current shell.
Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.
Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.
$END
$BUILTIN .
$DOCNAME dot
$FUNCTION source_builtin
$SHORT_DOC . filename [arguments]
Execute commands from a file in the current shell.
Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.
Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.
$END
References
- path: root/builtins/source.def
- What is the difference between “source” and “.”?
The dot command was introduced by the Bourne Shell most likely in 1976.
The source command was introduced by the csh in 1977 or 1978.
So there is not an alias relation but two different names for an "invention" at the same time.
BTW: I can tell you why cd
is named this way. The command previously had been called chdir
, but this was too long (slow to type) for the upcoming 110 Baud modems in 1974...