What is the difference between source <script>
and ./<script>
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
source script.sh
runs the script within the current process, thus all variable assignments are preserved as variables even after the script finishes (and don't have to be explicitly export
'd).
./script.sh
just runs the script in a subprocess, and any variables which are assigned disappear after the script is done.
回答2:
source script will change your current environment, ./script will not.
(EDIT: script has to be executable to use ./)