Fork
Usage: fork/directory/script. Sh
Fork is the most common. It uses/directory/script. Sh directly in the script to call the script. Sh script.
Run a sub-shell script to execute the call. When Sub-shell is executed, parent-shell is still running.
After sub-shell is executed, the system returns parent-shell. Sub-shell to inherit environment variables from parent-shell. However, the environment variables in sub-shell will not be brought back to parent-shell.
Exec
Usage: exec/directory/script. Sh
Unlike fork, exec does not require a new sub-shell to execute the called script. The called script and the parent script are executed in the same shell. However, after exec is used to call a new script, the content after the exec line in the parent script will not be executed again. This is the difference between exec and source.
Source
Usage: Source/directory/script. Sh
The difference with fork is that instead of opening a sub-shell to execute the called script, it is executed in the same shell. therefore, the variables and environment variables declared in the called script can be obtained and used in the main script.