Technotes

Technotes for future me

Source

Bourne Shell Builtins

Source

. (a period)

. filename [arguments]

source filename

This will run within the existing shell, ensuring any variables created or modified by the script will be available after the script completes. Running the script just using the filename will execute the script in a separate subshell.

Read and execute commands from the filename argument in the current shell context.
If filename does not contain a slash, the PATH variable is used to find filename.
When Bash is not in POSIX mode, the current directory is searched if filename is not found in $PATH.
If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged.
If the -T option is enabled, source inherits any trap on DEBUG; if it is not, any DEBUG trap string is saved and restored around the call to source, and source unsets the DEBUG trap while it executes.
If -T is not set, and the sourced file changes the DEBUG trap, the new value is retained when source completes.
The return status is the exit status of the last command executed, or zero if no commands are executed.
If filename is not found, or cannot be read, the return status is non-zero. This builtin is equivalent to source.

<http://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Bourne-Shell-Builtins

Last updated on 31 Jan 2021
Published on 3 Dec 2020
Edit on GitHub