Bug 21806 - bash reads startup files multiple times when invoked as a login shell
bash reads startup files multiple times when invoked as a login shell
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-12-06 11:43 EST by Need Real Name
Modified: 2007-04-18 12:30 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-01-24 18:02:58 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2000-12-06 11:43:58 EST
When bash is invoked as a login shell it seems to read the startup
files multiple times.  Try adding echo statements to .bash_profile,
.bashrc, and .profile and watch while executing "su - <user_name>
It's quite interesting and seems quite broken.  I wonder if this is
the reason for some of the hacks in the startup files.
Comment 1 Daniel Roesen 2000-12-07 06:53:29 EST
I think I noticed the same some time ago.
Comment 2 Patrick C. F. Ernzer 2001-12-15 13:21:24 EST
speaking of hacks, could we add the following to keep the $PATH from becoming
longer every time a new shell is opened:

[root@calm-horizons skel]# pwd
/etc/skel
[root@calm-horizons skel]# diff -c .bash_profile-orig .bash_profile
*** .bash_profile-orig  Sat Dec 15 18:12:57 2001
--- .bash_profile       Sat Dec 15 18:14:18 2001
***************
*** 7,13 ****
  
  # User specific environment and startup programs
  
! PATH=$PATH:$HOME/bin
  
- export PATH
  unset USERNAME
--- 7,16 ----
  
  # User specific environment and startup programs
  
! MYBIN=$HOME/bin
! if [ -z `echo ":${PATH}:"|grep ${MYBIN}` ] ; then
!         export PATH="$PATH:${MYBIN}"
! fi
! unset MYBIN
  
  unset USERNAME
Comment 3 Phil Knirsch 2002-07-23 05:32:48 EDT
I've just checked, and all the mentioned problems have been addressed in the
current release. If i add an echo "FOOBAR was here" to .bashrc_profile it only
gets printed once, just as expected.

Also, the $PATH doesn't get longer anymore.

Read ya, Phil

Note You need to log in before you can comment on or make changes to this bug.