后来根据版主的
提示,整理了一下贴子:为什么一个脚本直接执行和用source执行不一行呢?这也是我自己碰到的一个问题。manual原文是这样的:Read
and execute commands from filename in the current shell environment and
return the exit status of the last command executed from
filename.明白了为什么不一样了吧?直接执行一个脚本文件是在一个子shell中运行的,而source则是在当前shell环境中运行的。根据
前面的内容,你也已经明白其中的道理了吧。