LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Editing .bashrc

[ILUG] Editing .bashrc

Brian Foster blf at utvinternet.ie
Thu Apr 15 19:24:10 IST 2004


  | Date: Thu, 15 Apr 2004 16:07:49 +0100
  | From: Peter McEvoy <pete at yerma.org>
  | 
  | On Thu, Apr 15, 2004 at 04:04:37PM +0100, Timothy Murphy wrote:
  |  > Isn't .bashrc normally read several times?
  |  > I've never been clear what should go in .bashrc
  |  > and what in .bash_profile.
  |  > I've always assumed the latter was read only once,
  |  > but I could easily be wrong.
  | 
  | It might be worth taking a look at the INVOCATION section of
  | the bash(1) man page.

 indeed.
 the quick rule-of-thumb is the profile is read at
 login and never again;
 and “the‟ rc is read each time the shell is exec'ed
 (except, just to be confusing, by login shells).

 hence, it follows that the profile is perhaps best
 used for things passed from parent to child (e.g.,
 environment variables, including PATH); or which
 should only be done once and/or by the login shell
 (e.g., terminal initialization or printing fortune),

 the rc should be used for things which are not,
 or cannot be, inherited from the parent (e.g.,
 aliases and functions); or which are inherently
 local (e.g., controls on history and command
 completion (which are per-shell instance)).

 it is common for the profile to `.' the rc.

 it is rather bad form for the rc to print anything,
 or request input --- it is run when a script is
 launched and/or when non-interactive (but see below),
 and in those cases you generally don't want "spurious"
 output or prompts.

 please note there is fine-grained control over
 which file(s) are read (e.g., the interactive and
 non-interactive rc files need not be the same);
 consult the “INVOCATION‟ section of bash(1).
 but the gross rule of thumb that profile is read
 by the login shell only, and rc is read all other
 shell instances, works quite well (despite being
 technically inaccurate).

cheers!
	-blf-
--
«How many surrealists does it take to    |  Brian Foster      Montpellier,
 change a lightbulb?  Three.  One calms  |  blf at utvinternet.ie      France
 the warthog, and two fill the bathtub   |    Stop E$$o (ExxonMobile)!
 with brightly-colored machine tools.»   |        http://www.stopesso.com



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell