What startup scripts—in the order that they are called—set the PATH variable when opening a BASH shell in Terminal.app on OS X?
views:
40answers:
1
+1
A:
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:
- Directories in the file
/etc/pathsare added toPATH - Directories listed in the files in the directory
/etc/paths.d/are appended toPATH— Note, that these are appended versus being prepended. - Various
PATH={DIR_2_ADD}:"${PATH}"statements in my~/.bash_profileand~/.bashrcfiles are prependPATH
Matthew Rankin
2010-09-25 22:08:17