Bug 5133 - poor structure of bash dot files (setting prompt in 2 files)
poor structure of bash dot files (setting prompt in 2 files)
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
6.0
i386 Linux
low Severity low
: ---
: ---
Assigned To: Cristian Gafton
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-09-14 13:05 EDT by David Golden
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-10-05 01:56:46 EDT
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 David Golden 1999-09-14 13:05:56 EDT
This is a minor and cosmetic bug report about the
default structure of bash dot files:
/etc/bashrc
/etc/profile
/etc/skel/.bashrc
/etc/skel/.bash_profile

(Note, these are spread over *three* packages: bash, setup,
and etcskel.)

Irritated and inspired by the fact that the default files
set the prompt in two places because someone couldn't figure
it out, I think I have it figured out and have a suggestion
for fixing it.

From the bash man page, bash initializes itself differently
under login and non-login conditions:

Under login, it loads /etc/profile (if it exists) and
then ~/.bash_profile (if it exists).

Under non-login, it loads .bashrc (if it exists)

The default files with Redhat do roughly the
following:
/etc/profile -- sets up a bunch of stuff, including
environment, umask, and prompt
~/.bash_profile -- source ~/.bashrc
~/.bashrc -- source /etc/bashrc
/etc/bashrc -- set the prompt (again!)

Under a login shell, this flows smoothly in order.  But
under a non-login shell, bash only starts at ~/.bashrc,
doing nothing of the nice stuff in /etc/profile.  All the
real work gets done upfront where it can be skipped!  This
explains why the prompt has to be set again in /etc/bashrc.

I prefer the following setup:
/etc/profile -- does nothing!  (no global executables)
~/.bash_profile -- sources ~/.bashrc
~/.bash_rc -- sources /etc/bashrc, sets prompts (since users
typically customize this anyway!), aliases, and functions
/etc/bashrc -- sets environments, paths, umasks, etc (i.e.,
all the stuff that /etc/profile used to do.)

The advantage here is that regardless of whether bash is
login or non-login, all the work gets done at the end via
the same set of ~/.bashrc and /etc/bashrc files.

For an example of my actual files, look at:
http://hyperbolic.net/dotfiles.tar

As an aside, the /etc/profile.d mechanism of allowing
packages to customize the support they get from shell
environements or aliases probably shouldn't be triggered out
of /etc/profile for the same reasons I've outlined above,
but out of /etc/bashrc instead.  (I've not yet made this
change in my own dotfiles, however.)

I'm not sure how this plays out with other shells default
methods of loading dotfiles, but it at least seems to be a
more logical approach to the default bash configuration.

David Golden <david@hyperbolic.net>
Comment 1 Cristian Gafton 1999-10-05 01:56:59 EDT
You're trying to hash out the differences between a login shell and a
non-login shell. The difefrences exist for a reason, and your
workaround is a matter of taste and preference that I'm not going to
argue about...

This is just a matter of config files, and you seem to have figured
out the environment you like. What we have now might not be the best
setup, but at least is the least hated one...

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