Introduction to Unix |
|
![]() |
![]() |
4.15. source¶
-
source
Execute a shell script using the current shell.
SYNOPSIS
source script [ARGS …]
. script [ARGS …]
Note
The source command and a period followed by a space, ., are equivalent.
The shell script is ran within the current shell. That is to say, the shell does not first fork() and start a new shell to run the script. The primary reason for sourcing a script is if the script will assign environment variables. By using source, the variables may be set in the current shell.
There is sometimes confusion between source and exec, because exec also does not fork() first. The intent of exec is to replace the shell with a new program, i.e., the current shell does not run again.