From a Bash shell, which of the following commands directly executes the instruction from the file /usr/local/bin/runme.sh without starting a subshell? (Please select TWO answers.)
A.
source /usr/local/bin/runme.sh
B.
. /usr/local/bin/runme.sh
C.
/bin/bash /usr/local/bin/runme.sh
D.
/usr/local/bin/runme.sh
E.
run /usr/local/bin/runme.sh
题解
「source」指令可以在当前 shell 下运行某个 shell script 文件,因此在这 shell script 文件运行时若有对变量进行修改,也会影响到原本的 shell。
「sh」或是「xsh」(如 bash)这样的 shell script 文件运行方式,会产生新的子 shell(subshell) 来运行。
选项 A,正确答案。
选项 B,使用「.」来运行 shell script 文件,等同于使用「source」来运行 shell script 文件,并不会产生新的子 shell。为正确答案。
选项 C,会产生新的子 shell。
选项 D,直接运行 shell script 文件,会产生新的子 shell。
选项 E,没有「run」这种指令。
