更新时间:2023-11-21 11:34:40
通过运行脚本无法实现.该脚本会产生它自己的子外壳,脚本完成后会丢失.
This is not possible by running the script. The script spawns it's own sub-shell which is lost when the script completes.
为了保留脚本中可能包含的 export
,请对其进行调用
In order to preserve export
s that you may have in your script, call it
. myScript.sh
source myScript.sh
注意.
和 myScript.sh
之间的空间;还请注意," source
是的同义词.
在Bash中,但在POSIX sh
中不是,因此为了获得最大的兼容性,请使用句点"
Notice the space between the .
and myScript.sh
; also note that "source
is a synonym for .
in Bash, but not in POSIX sh
, so for maximum compatibility use the period."