“source script.sh"和“source script.sh"有什么区别?和“./script.sh"? [英] What is the difference between "source script.sh" and "./script.sh"?
本文介绍了“source script.sh"和“source script.sh"有什么区别?和“./script.sh"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
source
和 ./
有什么区别?
推荐答案
source script.sh
在当前进程内运行脚本,因此即使在脚本完成后,所有变量赋值仍保留为变量(并且不必显式export
'd).
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
只是在子进程中运行脚本,脚本完成后分配的任何变量都会消失.
./script.sh
just runs the script in a subprocess, and any variables which are assigned disappear after the script is done.
这篇关于“source script.sh"和“source script.sh"有什么区别?和“./script.sh"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文