LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
[stats]
From: Andrew Burrow <alburrow@cs.adelaide.edu.au>
To : John Kennison <marjon@mindless.com>
Date: Wed, 01 Nov 2000 09:13:53 +1030
Re: .bashrc and Debian 2.2
RE: sourcing of .bashrc file.
> I have a few alias set up in .bashrc under my home directory however they do
> not load on boot. If you open an xterm or that the settings are detected, but
> if I want them to work at the plain console I must manualy 'source ~/.bashrc'
> which is an inconvience to say the least.
Sometime ago I answered a similiar question on this, so you may find
something interesting in the mailling list archives.
The gist of it is that bash has some surprising policy wrt sourcing
these files. In particular, there is a strange mixture between the
cases of login/non-login and interactive/non-interactive shell. You
can _just_ work it out if you pour over the man page ;-).
Basically, .bashrc is sourced by an interactive shell, but not by a
login-shell. Therefore your login profile should source .bashrc if it
is interactive. RedHat have _hacked_ around this forever, by setting
ENV to point to .bashrc, which causes it to be loaded even by
non-interactive shells.
Here is the outline of my solution:
+ In "~/.bash_profile": at the end of the script I sense whether
the shell is interactive and source the resources as appropriate
# Get aliases and functions.
#
# This is a strange peculiarity of the shell. During a login shell
# the resources are never read, even if the shell is interactive.
# Therefore we test whether the PS1 variable is set to determine if
# the shell is an interactive login shell --- not an uncommon
# occurrence.
if [ "${PS1:-NONE}" != "NONE" ] ; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
elif [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
fi
+ In "~/.bashrc" I load the system wide resources.
# Source global aliases and functions.
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
OK. Looking at this again maybe it would be better if I sourced
"/etc/bash.bashrc" in "/etc/profile", in the same way as above, and then
load the personal resources in "~/.bash_profile" ---- whatever.
> On a similar note, in /etc/ I have a file called "bash.bashrc" which
> claims to the system-wide default .bashrc file. Is this the correct
> name for the file?? It just seems to be a different naming convention
> to the /etc/profile file.
Given that you should source these files from the profiles, I
think that you could call it slarty bartfast if you wished ;-).
Maybe the man page says something, though I don't recall.
Cheers,
Andrew
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
[stats]
Return to the LinuxSA Mailing List Information Page