哪些文件影响 bash on Mac OS X 中的路径?
Which files affect the path in bash on Mac OS X?
我正在调试一个 bash
程序,我对如何在 Mac OS X 中设置 PATH
感到有点困惑。例如,我有一台相对较新的笔记本电脑,它安装了 Server.app
和 homebrew
,但没有其他东西。当我删除 ~/.bashrc
和 ~/.bash_profile
文件并执行 echo $PATH
时,我得到:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin
我的PATH
是如何修改的?
你要找的是 path_helper
来自 man path_helper
The path_helper utility reads the contents of the files in the directo-
ries /etc/paths.d and /etc/manpaths.d and appends their contents to the
PATH and MANPATH environment variables respectively. (The MANPATH envi-
ronment variable will not be modified unless it is already set in the
environment.)
Files in these directories should contain one path element per line.
Prior to reading these directories, default PATH and MANPATH values are
obtained from the files /etc/paths and /etc/manpaths respectively.
如果你看到它在 /etc/profile
中被调用
[~] cat /etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
我正在调试一个 bash
程序,我对如何在 Mac OS X 中设置 PATH
感到有点困惑。例如,我有一台相对较新的笔记本电脑,它安装了 Server.app
和 homebrew
,但没有其他东西。当我删除 ~/.bashrc
和 ~/.bash_profile
文件并执行 echo $PATH
时,我得到:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin
我的PATH
是如何修改的?
你要找的是 path_helper
来自 man path_helper
The path_helper utility reads the contents of the files in the directo-
ries /etc/paths.d and /etc/manpaths.d and appends their contents to the
PATH and MANPATH environment variables respectively. (The MANPATH envi-
ronment variable will not be modified unless it is already set in the
environment.)
Files in these directories should contain one path element per line.
Prior to reading these directories, default PATH and MANPATH values are
obtained from the files /etc/paths and /etc/manpaths respectively.
如果你看到它在 /etc/profile
中被调用[~] cat /etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi