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