Three different methods (fork, exec, source) fork (/directory/script. sh) fork is the most common, that is, directly using/directory/script in the script. sh 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, return parent-shell. sub-shell inherits environment variables from parent-shell. however, the environment variables in sub-shell do not bring back parent-shell exec (exec/directory/script. sh) exec is different from fork. You do not need to create 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 (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. you can use the following two scripts to understand the differences between the three call Methods: 1.sh #! /Bin/bashA = B echo "PID for 1.sh before exec/source/fork: $" export Aecho "1.sh:\ $ A is $ A" case $1 in exec) echo "using exec... "Exec./2.sh; source) echo" using source... "../2.sh; *) echo" using fork by default... "./2.sh; esacecho" PID for 1.sh after exec/source/fork: $ "echo" 1.sh:\$ A is $ A "2.sh #! /Bin/bashecho "PID for 2.sh:$ $" echo "2.sh get \ $ A = $ A from 1.sh" A = Cexport Aecho" 2.sh:\ $ A is $ A "execution status: $. /1.sh PID for 1.sh before exec/source/fork: 58453641.sh: $ A is Busing fork by default... PID for 2.sh: 52429402.sh get $ A = B from 1. sh2.sh: $ A is CPID for 1.sh after exec/source/fork: 58453641.sh: $ A is B $. /1.sh execPID for 1.sh before exec/source/fork: 55626681.sh: $ A is Busing exec... PID for 2.sh: 55626682.sh get $ A = B from 1. sh2.sh: $ A is C $./1.sh source PID for 1.sh before exec/source/fork: 51568941.sh: $ A is Busing source... PID for 2.sh: 51568942.sh get $ A = B from 1. sh2.sh: $ A is CPID for 1.sh after exec/source/fork: 51568941.sh: $ A is C $