This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bash is backwards, or I can't read a man page.


"Matthew O. Persico" wrote:
> 
> Earnie Boyd wrote:
> >
> > "Matthew O. Persico" wrote:
> > >
> > > According to what I get from the manpage, the order of execution for a
> > > login shell should be:
> > >
> > > /etc/profile
> > > ~/.bash_profile
> > > ~/.bashrc
> > >
> > > When I login, I see
> > > /etc/profile
> > > ~/.bashrc
> > > ~/.bash_profile
> > >
> > > because /etc/profile tests for ./.bashrc and runs it itself.
> > >
> > > Is this a bug or a feature? Does someone have a clearer explanation of
> > > what stuff goes into .bash_profile and what goes into .bashrc and when
> > > they get called? Maybe it's just me - I can't grok this in ksh using the
> > > O'Reilly book either.
> > >
> >
> > IMO, the test for ~/.bashrc should go into the ~/.bash_profile file.
> > Bash doesn't grok the ~/.bashrc file during --login so it needs to get
> > sourced by a profile file.  Since more than one shell groks the
> > /etc/profile file then specifics for a particular brand of shell should
> > be kept to a minimum.  Once upon a time Cygwin only shipped with one
> > interactive shell, so when setup.exe, which is what creates /etc/profile
> > in the first place, was created the designers chose to test for
> > ~/.bashrc globally because it would cause less mail list traffic.
> >
> > Now what should go in profile and what should go in bashrc?  The profile
> > should be used define variables and setup a login account that any shell
> > can grok.  The bashrc should contain bash specific things such as
> > aliases.  Note the /etc/profile and ~/.bash_profile isn't read during
> > non-login execution because those things should be passed to the child
> > while alias won't be.
> 
> Well, that's just about the most coherent explanation I've ever heard
> and if I stretch my brain, it jibes with what I think I've been reading,
> just a hell of a lot more simple.
> 
> One last point; non-login execution is any bash script/binary executable
> called from the command line or inside another script/executable, yes?
> 

Yes, anything that causes bash to fork.  Also, if you start bash from
the command line without the --login switch it is a non-login shell.

Earnie.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]