ubuntu8.04終端機好像預期不去讀.bash_ … - Linux

By Megan
at 2008-11-25T16:21
at 2008-11-25T16:21
Table of Contents
※ 引述《dogtsing (颺)》之銘言:
: bash -l
: 我的shell就會去讀.bash_profile
: 問題:
: 1.不曉得是哪裡觀念不足, 為啥平實shell不去讀.bash_profile
: 但用 bash -l就會去讀?
: 2.有可能設定成開啟終端機時可以自動去讀 .bash_profile嗎?
: 謝謝!!
man bash 的時候可以看到這麼一段
-l Make bash act as if it had been invoked as a
login shell(see INVOCATION below).
OK, 那繼續往下看看 INVOCATION 那一段
When bash is invoked as an interactive login shell, or as a non-interactive
shell with the --login option, it first reads ...(skip) After reading
that file, it looks for ~/.bash_profile
這說明了為什麼 -l 的選項就會去讀 ~/.bash_profile
至於問題一也有這麼一段可以解釋
When an interactive shell that is not a login shell is started, bash
reads and executes commands from /etc/bash.bashrc and ~/.bashrc
它只讀 /etc/bash.bashrc 以及 ~/.bashrc
問題二的解法,就是在 ~/.bashrc 或 /etc/bash.bashrc 裏面讓它去讀
.bash_profile 就可以了。
但這並不是好的解法。
之所以會有這些 behavior,我猜想是因為當初設計的時候認為
「以不同的方式 invoke,就該讀進不同的檔案」
與其讓它強制去讀 .bash_profile,不如好好區別你想增加的行為,放在適合的地方。
--
我想你會衰成這樣都是我害的
---- Tizzy Mac
緊張的麥金塔?這是誰(._.?)
--
: bash -l
: 我的shell就會去讀.bash_profile
: 問題:
: 1.不曉得是哪裡觀念不足, 為啥平實shell不去讀.bash_profile
: 但用 bash -l就會去讀?
: 2.有可能設定成開啟終端機時可以自動去讀 .bash_profile嗎?
: 謝謝!!
man bash 的時候可以看到這麼一段
-l Make bash act as if it had been invoked as a
login shell(see INVOCATION below).
OK, 那繼續往下看看 INVOCATION 那一段
When bash is invoked as an interactive login shell, or as a non-interactive
shell with the --login option, it first reads ...(skip) After reading
that file, it looks for ~/.bash_profile
這說明了為什麼 -l 的選項就會去讀 ~/.bash_profile
至於問題一也有這麼一段可以解釋
When an interactive shell that is not a login shell is started, bash
reads and executes commands from /etc/bash.bashrc and ~/.bashrc
它只讀 /etc/bash.bashrc 以及 ~/.bashrc
問題二的解法,就是在 ~/.bashrc 或 /etc/bash.bashrc 裏面讓它去讀
.bash_profile 就可以了。
但這並不是好的解法。
之所以會有這些 behavior,我猜想是因為當初設計的時候認為
「以不同的方式 invoke,就該讀進不同的檔案」
與其讓它強制去讀 .bash_profile,不如好好區別你想增加的行為,放在適合的地方。
--
我想你會衰成這樣都是我害的
---- Tizzy Mac
緊張的麥金塔?這是誰(._.?)
--
Tags:
Linux
All Comments

By Rae
at 2008-11-26T15:17
at 2008-11-26T15:17
Related Posts
yum 安裝gromacs

By Enid
at 2008-11-25T15:07
at 2008-11-25T15:07
KatDC Open Space Forum 消費性電子開發技術論壇

By Franklin
at 2008-11-25T14:46
at 2008-11-25T14:46
多語版 PCMan X v0.3.8

By Franklin
at 2008-11-25T14:24
at 2008-11-25T14:24
如果預設關掉蜂鳴器--ubuntu8.04

By Frederic
at 2008-11-25T12:30
at 2008-11-25T12:30
ubuntu8.04終端機好像預期不去讀.bash_profile

By Hazel
at 2008-11-25T12:19
at 2008-11-25T12:19