什么启动脚本 - 按照它们被调用的顺序 - 在OS X上的Terminal.app中打开BASH shell时设置PATH
变量?
I've found the culprit. The secret sauce was /usr/libexec/path_helper
it looks in the file /etc/paths
and in the directory /etc/paths.d/
.
First bash
sources /etc/profile
which executes the following code:
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
Next bash
looks for ~/.bash_profile
, ~/.bash_login
, and ~/.profile
.
Listing these steps out, PATH
is built as follows:
/etc/paths
are added to PATH
/etc/paths.d/
are appended to PATH
— Note, that these are appended versus being prepended. PATH={DIR_2_ADD}:"${PATH}"
statements in my ~/.bash_profile
and ~/.bashrc
files are prepend PATH
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.