Bug 5133 - poor structure of bash dot files (setting prompt in 2 files)
Summary: poor structure of bash dot files (setting prompt in 2 files)
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash
Version: 6.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 1999-09-14 17:05 UTC by David Golden
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 1999-10-05 05:56:46 UTC

Attachments (Terms of Use)

Description David Golden 1999-09-14 17:05:56 UTC
This is a minor and cosmetic bug report about the
default structure of bash dot files:

(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
/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:

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 05:56:59 UTC
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.