Re: [問題] ubuntu8.04終端機好像預期不去讀.bash_ …

看板Linux作者 ( 殺手哥吉拉 13)時間15年前 (2008/11/25 16:21), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/2 (看更多)
※ 引述《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 緊張的麥金塔?這是誰(._.?) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.219.5.210

11/28 01:58, , 1F
好文推~ 又上了一課! 謝謝!
11/28 01:58, 1F
文章代碼(AID): #19AxMR9v (Linux)
文章代碼(AID): #19AxMR9v (Linux)