From: rwp@hpfcla.fc.hp.com (Bob Proulx)
Subject: Re: Won't read .bashrc
Organization: Fort Collins, CO
Distribution: gnu
Date: Tue, 15 Dec 1992 22:15:48 GMT

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.


Newsgroups: gnu.bash.bug