哪些文件影响Mac OS X上的bash路径?

时间:2015-07-07 00:06:03

标签: macos bash shell command-line terminal

我正在调试bash程序,我对如何在Mac OS X中设置PATH感到困惑。例如,我有一台相对较新的笔记本电脑Server.app安装了1}}和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如何被修改?

1 个答案:

答案 0 :(得分:2)

您要找的是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