🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #973

Re: Won't read .bashrc

#973
From: Bob Proulx
Date: Tue, 15 Dec 1992 22:15
91 lines
3641 bytes
In article <jtarr.724364430@husc8> you wrote:
: bash doesn't seem to read my .bashrc file when I login.  It does read
: my .bash_profile and .profile files, but not my .bashrc.

The solution is to source your .bashrc file in your .profile.  This is
different than either ksh or csh but I like the new behavior.  It
gives more control over the problem.

	. $HOME//.bashrc

Following is just more explaination so skip on if you already know this.

>From the manual:
      Login shells:
        On login:
              if /etc/profile exists, source it.

              if ~/.bash_profile exists, source it,
                else if ~/.bash_login exists, source it,
                  else if ~/.profile exists, source it.

        On logout:
              if ~/.bash_logout exists, source it.

      Non-login interactive shells:
        On startup:
              if ~/.bashrc exists, source it.

      Non-interactive shells:
        On startup:
              if the environment variable ENV is non-null, expand
           it and source the file it names.

So the manual says that bash does not read the .bashrc file if the
shell is a login shell.  I suggest using one .profile for ksh and
bash.  In the .profile source the .bashrc file for bash.

I run different shells on different machines because I can't always
install my favorite shell everywhere.  My .profile uses a case
statement to switch between them.  I post it only as an example.

case "$SHELL" in
*bash)
  # bash only vars
  export SHELL=/bin/bash
  export HISTFILE=$HOME//.bash_history
  export FIGNORE="~:.o:.a:.h"
  export auto_resume=1
  export no_exit_on_failed_exec=1
  . $HOME//.bashrc
  unset ENV  # Just in case.
  ;;
*ksh)
  # ksh only vars

  # From the KornShell book.  Does not work with ksh86. :-(
  # export ENV='${FILE[ (_$-=0) + (_=1) - _${-%%*i*} ]}'
  # Hack to only load .kshrc if interractive.  Works with ksh86
  export ENV='${START[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
  export START=$HOME//.kshrc

  export SHELL=/bin/ksh
  export HISTFILE=$HOME//.sh_history
  ;;
esac

Why I use two slashes:  I always use $HOME//filename because on Apollo
and apparently OSF you can specify //machinename/filename.  This is
allowed by POSIX which I think says that leading 1 or 3-n slashes
equal one slash and 2 slashes might mean anything.  If I use bash for
root and have root's home in / then $HOME will be a single slash.
$HOME/file will become //file which might be interpreted as a machine
name instead.  Whew!

: As a result my PATH is not set correctly which just wreaks havok
: later.

I personally don't like setting PATH in the rc file.  Set it in
your .profile and let all other shells inherit the environment.  Its
faster anyway.  My suggestion is to put as little as possible in
the .bashrc file.

: I'm switching to bash from csh.  I'm only a bash beginner so I

We all have to start somewhere!  I think you have made a fine choice.

Bob Proulx
rwp@fc.hp.com

Not an official statement of my employer, its just my opinion.  I
don't even have official opinions unless I say so.
Technical Details
Message-ID: <BzBn6C.KnB@fc.hp.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!uwm.edu!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!hpfcla.fc.hp.com!rwp
References: <jtarr.724364430@husc8>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.bash.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!uwm.edu!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!hpfcla.fc.hp.com!rwp
From: rwp@hpfcla.fc.hp.com (Bob Proulx)
Subject: Re: Won't read .bashrc
Message-ID: <BzBn6C.KnB@fc.hp.com>
Sender: gnulists@ai.mit.edu
Organization: Fort Collins, CO
References: <jtarr.724364430@husc8>
Distribution: gnu
Date: Tue, 15 Dec 1992 22:15:48 GMT
Approved: bug-bash@prep.ai.mit.edu
Lines: 93