On Mon, Aug 26, 2002 at 10:29:40AM -0700, Gordon Messmer wrote:
> On Mon, 2002-08-26 at 10:01, Robert P. J. Day wrote:
> > 
> > IMHO, setting the alias should go in your ~/.bashrc, while setting
> > the command line prompt should go in ~/.bash_profile.
> 
> Anything used specifically by the interactive shell should go in
> .bash_profile.  That includes both your prompts and your aliases. 
> .bashrc will be used by all instances of bash you run, including shell
> scripts, so the shorter and more concise it is, the better off you are.

If I might qualify this a bit, and based on my understanding ....
.bash_profile is sourced for interactive login shells only (or other
shell started with --login option). .bashrc is not sourced
automatically in such situations (according to my reading of the man
page anyway). But is usually sourced by .bash_profile (which is why I
asked this before). Assuming, this is the case, then yes .bashrc is
always sourced. Interactive shells that are not login shells, and
non-interactive shells source .bashrc only. Also, the system wide
equivalents, of course for both cases.

Where this might cause confusion, is say where you open 
terminal apps (rxvt, etc) from the same parent login shell, but these
sub-shells are not login shells. These probably will only source
.bashrc, so having special magic (like aliases) in .bash_profile needs
to be accounted for one way or the other. One way is to do whatever
voodoo is needed to make them login shells. Or have .bashrc do
whatever voodoo when it detects an interactive shell (which might not
be a login shell and thus bash ignores *bash_profile). I do this with:

if [ "$PS1" ]; then
 . ~/.aliases
 . ~/.functions

[...]

This works for the interactive non-login situation. And 
non-interactive shells don't see all the stuff in the 'if' section.

Please correct if wrong :)

-- 
Hal Burgiss
 



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to