Hack 84. .bash_* を順番に実行する
次のファイルはどのような順で実行されるでしょうか?
o /etc/profile
o ~/.bash_profile
o ~/.bashrc
o ~/.bash_login
o ~/.profile
o ~/.bash_logout
ログインシェルを順番に実行する
次の仮想コードはこれらのファイルの実行順を示しています。
execute /etc/profile
IF ~/.bash_profile exists THEN
execute ~/.bash_profile
ELSE
IF ~/.bash_login exist THEN
execute ~/.bash_login
ELSE
IF ~/.profile exist THEN
execute ~/.profile
END IF
END IF
END IFインタラクティブシェルからログアウトするときは次のような実行順になります:
IF ~/.bash_logout exists THEN
execute ~/.bash_logout
END IF/etc/bashrc は以下に示すように ~/.bashrc から実行されることに注意してください:
# cat ~/.bashrc if [ -f /etc/bashrc ]; then . /etc/bashrc Fi
ログインしないインタラクティブシェルを順番に実行する
ログインせずにインタラクティブシェルを起動するときは以下のような実行順になります:
IF ~/.bashrc exists THEN
execute ~/.bashrc
END IFNote: ログインしないインタラクティブシェルが起動するときに、ENV 環境変数を探します。
ENV 変数内にある file-name の値を実行します。