2008年3月28日金曜日

/usr/libexec/path_helper

ふとシェルの環境変数の読み込みファイルはどんな順番だったか思い出したくなった。

man bash より引用 
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.

  1. /etc/profile
  2. ~/.bash_profile
  3. .bash_login
  4. .profile

の順でさがし、最初に見つかったもの1つを読み込むと。

interactive だけど login shell でない場合は、

man bash より引用
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
~/.bashrc のみ読みこむ

/etc/profileを覗いてみると

# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s`
eval `/usr/libexec/path_helper -s` fi
fi
if [ "${BASH-no}" != "no" ]; then
if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc
[ -r /etc/bashrc ] && . /etc/bashrc fi
fi
となっている。この /usr/libexec/path_helper -s を実行してみると
PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"; export PATH
MANPATH="/usr/share/man:/usr/local/share/man:/usr/X11/man"; export MANPATH
man path_helper すると、-s は Bourne shell 用で、 -c が C-shell 用の出力をするとあり、参照先はそれぞれ
  • PATH: /etc/paths, /etc/paths.d/以下のファイル
  • MANPATH: /etc/manpaths, /etc/manpaths.d/以下のファイル

0 件のコメント:

コメントを投稿