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.



Relevant Pages

  • Re: [kde] Konsole in English
    ... konsole should be in a different language; ... .bashrc is a very good place to achieve that. ... executes commands from the file /etc/profile, ... "When an interactive shell that is not a login shell is started, ...
    (KDE)
  • Re: [kde-linux] KDE 4.0.3 "Unable to load library" problem
    ... Yes, I use dedicated user account kde-devel, as advised in the tutorial. ... > Note that I list a *lot* of environment variables that need to be set. ... I set my LD_LIBRARY_PATH according to tutorial in my .bashrc file (included in my origial post along the build logs) ...
    (KDE)
  • Re: [kde] Konsole in English
    ... konsole should be in a different language; ... .bashrc is a very good place to achieve that. ... if you want them to be effective only on the command line of bash ... invoke konsole from the command line, like so, ...
    (KDE)
  • Re: Full login sequence documentation ?
    ... subshell inherits all environment variables and exported shell ... The separation of .bash_proifle from .bashrc allows you to create a ... lighter weight .bashrc to speed up subshell creation by separating ...
    (comp.sys.mac.system)
  • .bashrc vs .bash_profile: sourcing scripts
    ... 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 ... This has led me to source .bashrc from .bash_profile and comment out ...
    (comp.unix.shell)