更新时间:2023-12-05 19:04:22
source 你的脚本,不要像 ./foo.sh
或 那样执行sh foo.sh
source your script, don't execute it like ./foo.sh
or sh foo.sh
如果你这样执行你的脚本,它会在子 shell 中运行,而不是你当前的.
If you execute your script like that, it is running in sub-shell, not your current.
source foo.sh
对你有用.