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

Megan avatar
By Megan
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

緊張的麥金塔?這是誰(._.?)

--
Tags: Linux

All Comments

Rae avatar
By Rae
at 2008-11-26T15:17
好文推~ 又上了一課! 謝謝!

yum 安裝gromacs

Enid avatar
By Enid
at 2008-11-25T15:07
小弟是很嫩的新手 用yum安裝gromacs灌了好久都灌不好 Loaded plugins: refresh-packagekit Could not retrieve mirrorlist http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-9 ...

KatDC Open Space Forum 消費性電子開發技術論壇

Franklin avatar
By Franklin
at 2008-11-25T14:46
Hi Everyone, 12/13的消費性電子開發技術論壇 (KatDC Open Space Forum)將針對3D技術從底層開發到 頂層應用等目前在消費性電子產業中最受注目之議題,分享彼此的開發經驗。 歡迎業界夥伴來一同分享技術及市場的看法與經驗。即日起可線上報名 http://www.katdc ...

多語版 PCMan X v0.3.8

Franklin avatar
By Franklin
at 2008-11-25T14:24
※ 引述《mstar (Wayne Su)》之銘言: : 因為 ubuntu 套件庫的 pcmanx 不支援顯示日文、簡體等, : 所以找了半年前某大的文來,參考用以將 0.3.8 版改造成多語版 : ↑ http://www.ptt.cc/bbs/PCman/M.1205 ...

如果預設關掉蜂鳴器--ubuntu8.04

Frederic avatar
By Frederic
at 2008-11-25T12:30
我知道 xset b off可以關 但是每次開機都要打一次有點煩 試過寫進.bashrc或是/etc/rc.local都沒有用 請問有人知道如何預設關掉蜂鳴器的嗎? 謝謝~ - ...

ubuntu8.04終端機好像預期不去讀.bash_profile

Hazel avatar
By Hazel
at 2008-11-25T12:19
因為和朋友共同開發軟體 不過他用的是Scientific Linux 而我是用ubuntu 8.04 我們寫的用來hooking環境變數的script裏面希望可以根據每人的OS不同去做調整 這時候我才發現原來好像ubuntu 8.04開終端機時不會去讀 .bash_profile (我平常習慣編輯.bashr ...