Thread View: gnu.bash.bug
2 messages
2 total messages
Started by Jeff Tarr
Mon, 14 Dec 1992 20:20
Won't read .bashrc
Author: Jeff Tarr
Date: Mon, 14 Dec 1992 20:20
Date: Mon, 14 Dec 1992 20:20
16 lines
922 bytes
922 bytes
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. As a result my PATH is not set correctly which just wreaks havok later. I'm switching to bash from csh. I'm only a bash beginner so I suspect that this is my fault, not a bug, but I have followed the man file exactly to no avail. Thanks. -- Jeff Tarr Harvard University jtarr@husc.harvard.edu -- Jeff Tarr Harvard University jtarr@husc.harvard.edu
Re: Won't read .bashrc
Author: Bob Proulx
Date: Tue, 15 Dec 1992 22:15
Date: Tue, 15 Dec 1992 22:15
91 lines
3641 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads