3
什么启动脚本 - 它们被调用的顺序 - 在OS X上的Terminal.app中打开BASH shell时设置变量PATH
?当在OS X上的Terminal.app中打开BASH shell时,PATH env变量是如何设置的?
什么启动脚本 - 它们被调用的顺序 - 在OS X上的Terminal.app中打开BASH shell时设置变量PATH
?当在OS X上的Terminal.app中打开BASH shell时,PATH env变量是如何设置的?
我发现了罪魁祸首。秘密酱油是/usr/libexec/path_helper
它看起来在文件/etc/paths
和目录/etc/paths.d/
。
首先bash
源/etc/profile
它执行以下代码:
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
# The above line is the secret sauce, so to say...
# First is adds default PATH values from the file /etc/paths
# Then all files in the /etc/paths.d/ directory are read and directories listed
# in each file (one per line) are appended to PATH
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
下一页bash
查找~/.bash_profile
,~/.bash_login
,和~/.profile
。
清单这些步骤进行,PATH
构建如下:文件/etc/paths
在
PATH
在目录中的文件中列出/etc/paths.d/
是附加到PATH
- 注,这些被附加与预先附加。~/.bash_profile
和~/.bashrc
文件的各种PATH={DIR_2_ADD}:"${PATH}"
语句前面加上PATH
环境变量也可以在这方面我想像继承。除非重置(不只是添加到),否则它可能会进一步在流程链上。但最接近我使用OS X的是一台搁置在书架上的死MacBook。 – 2010-09-25 22:15:51
不完全相关,但可能有用的是,您可以使用诸如“launchctl setenv PATH”之类的命令对* all *应用程序看到的PATH进行持久更改。 – rptb1 2013-07-10 16:52:41