Re: .bashrc vs .bash_profile: sourcing scripts

From: Bit Twister (BitTwister_at_localhost.localdomain)
Date: 10/08/04


Date: Fri, 08 Oct 2004 02:09:25 GMT

On 7 Oct 2004 18:49:35 -0700, relaxedrob@optushome.com.au wrote:
> Hi All!
>
> I am running RH9 and use bash through Konsole all the time.
>
> I have found that whenever I open Konsole or su from a Konsole session
> to any other user, .bash_profile is source/executed/? but .bashrc
> never is.

Hmm, thought .bash_profile sourced. Example:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc <==================
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

>
> This has led me to source .bashrc from .bash_profile and comment out
> code in .bashrc that sources .bash_profile.

See above copy from /etc/skel which is copied into new accounts
during account creation.

> More recently, I had to shift code that sources a script (that sets
> other environment variables) to my .bashrc because it wasn't working
> when I had it in .bash_profile.

Usually .bash_profile is only sourced during login spinning up another
terminal or xterm does not execute .bash_profile but does source .bashrc.

Now, the new session inherits environment variables which have been
exported from the parent process.

>
> http://phd.netcomp.monash.edu.au/RobertMarkBram/phd/globus/2004/globusBlog.asp#globus_user_profile
>
> Have I got the wrong idea about these files? Am I the only one who has
> had to change default code to get my system to work? :)

not me. Maybe there is a bug in .bashrc. turn on tracing and see what
you can see

put a
     set -xv
at the top of .bashrc and
     set -
at the bottom to prove everything ran correctly. To test do a

su -l $LOGNAME and watch what happens.