I wonder why a command that executes commands from a file in the current shell is named
source. I can't see a relation between run commands in the current shell and the meaning of the english word source. Is there a history behind that name?
A shell’s purpose is to read commands and execute them, whether that’s interactively or from a script. In that context, I’ve always thought of
source as specifying the source of the commands the shell should execute (reverting to the current source once it’s finished).
Bill Joy (who introduced
source in the C shell) defined the command thus:
The source command causes the shell to read commands from a specified file. It is most useful for reading files such as .cshrc after changing them.
VERB [WITH OBJECT]
- Obtain from a particular source.
Isn't that exactly what this command is doing? Obtaining variable, alias and function definitions, and other shell settings, from a particular file?