What does 'source' do?
source
is a bash shell built-in command that executes the content of the file passed as argument, in the current shell. It has a synonym in .
(period).
Syntax
. filename [arguments] source filename [arguments]
Be careful! ./
and source
are not quite the same.
./script
runs the script as an executable file, launching a new shell to run itsource script
reads and executes commands from filename in the current shell environment
Note: ./script
is not . script
, but . script
== source script
https://askubuntu.com/questions/182012/is-there-a-difference-between-and-source-in-bash-after-all?lq=1
It is useful to know the 'type' command:
> type source
source is a shell builtin
whenever something is a shell builtin it is time to do man bash
.