Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Apr 1999 07:31:23 -0500
From:      Lowell Gilbert <lowell@world.std.com>
To:        "Mike Roberts" <zoarre@bigfoot.com>, freebsd-questions@freebsd.org
Subject:   [freebsd-questions] bash startup scripts
Message-ID:  <rd6pv4re1sq.fsf@world.std.com>
In-Reply-To: "Mike Roberts"'s message of Sun, 25 Apr 1999 21:31:23 -0700
References:  <00a001be8f9d$f9182860$0100a8c0@kermit>

next in thread | previous in thread | raw e-mail | index | archive | help
"Mike Roberts" <zoarre@bigfoot.com> writes:

> I'm trying to make bash's startup files work, and the behavior that my
> installation exhibits does not seem to match the documentation that I have:
> 
> - The book, "The Complete FreeBSD" claims that bash executes '.profile', and
> then '.bashrc'.
> - The bash man page claims that it executes '.bash_profile' on login, and
> '.bashrc' for each shell (login shell also?).
> - My installation (the package installed with sysinstall) executes
> '.profile' on login, and executes '.bashrc' only when I execute bash again
> from the login shell.
> 
> Which behavior is correct? What do to obtain the proper behavior?

I don't have "The Complete FreeBSD," but you are misquoting the bash
man page.  What your installation does sounds correct, although there
are a few details that should be explained a little further.

When a login shell starts, bash first executes /etc/profile, if it
exists.  After that, it executes *exactly* *one* *of* ~/.bash_profile,
~/.bash_login, and ~/.profile.  The first one of those that's found,
wins.  The others won't be checked.

.bashrc is executed only by interactive shells that are *not* login
shells.  Personally, I don't find this behaviour helpful, so I have
.bash_login automatically drag in .bashrc; but then, the distinction
between login and non-login shells isn't helpful (i.e., you don't
normally *get* a login shell) when you're running under xdm.

If "The Complete FreeBSD" claims that bash automatically executes both
'.profile' and '.bashrc' for the *same* shell, then it's wrong, and
I'm sure Greg Lehey will want to fix that.

Be well.
        Lowell Gilbert


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?rd6pv4re1sq.fsf>