Discussion:
.bashrc not getting sourced?
Roland Glenn McIntosh
2002-03-26 16:37:42 UTC
Permalink
I just did a recent brand new install yesterday and I noticed that /etc/profile no longer contains a line like:

test -f ./.bashrc && . ./.bashrc

It took me a second to figure out why .bashrc wasn't getting read (I thought it happened automatically by the shell) until I compared it to an older "working" cygwin install.

Is there a specific reason for that missing line in /etc/profile, or could it have been an oversight? I did notice that my redhat 7 system's /etc/profile doesn't seem to include such a line.
-rgm



--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Randall R Schulz
2002-03-26 16:49:57 UTC
Permalink
Roland,

My /etc/profile contains exactly the line you quote. It is the last line of
that file, immediately following a "cd $HOME" command. This file bears the
modification date May 10, 2001. It may be a coincidence, but that's right
when I installed Cygwin for the first time on what was then a new, "clean"
Windows 2000 Professional installation on this disk.

Randall Schulz
Mountain View, CA USA
Post by Roland Glenn McIntosh
I just did a recent brand new install yesterday and I noticed that
test -f ./.bashrc && . ./.bashrc
It took me a second to figure out why .bashrc wasn't getting read (I
thought it happened automatically by the shell) until I compared it to an
older "working" cygwin install.
Is there a specific reason for that missing line in /etc/profile, or could
it have been an oversight? I did notice that my redhat 7 system's
/etc/profile doesn't seem to include such a line.
-rgm
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Peter Buckley
2002-03-26 17:02:54 UTC
Permalink
IIRC, if you check the archives, you should find that the behavior of
sourcing the .bashrc file in /etc/profile was discontinued in later
cygwin releases. The fact that you have it from over a year ago is
probably because the cygwin install does not overwrite files that have
been modified or exist previously.

HTH,
Peter
Post by Randall R Schulz
Roland,
My /etc/profile contains exactly the line you quote. It is the last line
of that file, immediately following a "cd $HOME" command. This file
bears the modification date May 10, 2001. It may be a coincidence, but
that's right when I installed Cygwin for the first time on what was then
a new, "clean" Windows 2000 Professional installation on this disk.
Randall Schulz
Mountain View, CA USA
Post by Roland Glenn McIntosh
I just did a recent brand new install yesterday and I noticed that
test -f ./.bashrc && . ./.bashrc
It took me a second to figure out why .bashrc wasn't getting read (I
thought it happened automatically by the shell) until I compared it to
an older "working" cygwin install.
Is there a specific reason for that missing line in /etc/profile, or
could it have been an oversight? I did notice that my redhat 7
system's /etc/profile doesn't seem to include such a line.
-rgm
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Roland Glenn McIntosh
2002-03-26 18:07:50 UTC
Permalink
I searched the archives and found a note from Larry suggesting that I review the archives for 12-03-2001. I did this for all of Nov, Dec, and Jan and did not find at least two mentions of the problem as he suggested.

My question is pretty simple: is editing the /etc/profile the recommended way to get my ~/.bashrc file sourced? And if not, what is.

It should be noted that I found a message by Gary R. Van Sickle suggesting that .bash_profile might be a better way to do things, but this doesn't directly answer my question.

-rgm
IIRC, if you check the archives, you should find that the behavior of sourcing the .bashrc file in /etc/profile was discontinued in later cygwin releases. The fact that you have it from over a year ago is probably because the cygwin install does not overwrite files that have been modified or exist previously.
HTH,
Peter
Post by Roland Glenn McIntosh
test -f ./.bashrc && . ./.bashrc
It took me a second to figure out why .bashrc wasn't getting read (I thought it happened automatically by the shell) until I compared it to an older "working" cygwin install.
Is there a specific reason for that missing line in /etc/profile, or could it have been an oversight? I did notice that my redhat 7 system's /etc/profile doesn't seem to include such a line.
-rgm
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
David Means
2002-03-26 18:52:43 UTC
Permalink
I believe that .bash_login, .bash_profile or .profile is the file
you're wanting to use in this instance.

man bash
{ snip }

When an interactive shell that is not a login shell is
started, bash reads and executes commands from ~/.bashrc, if
that file exists. This may be inhibited by using the --norc
option. The --rcfile file option will force bash to read
and execute commands from file instead of ~/.bashrc.

{ snip }

If you're realling wanting .bashrc to be sourced on a login-shell, then
you'll either need to set BASH_ENV=$HOME/.bashrc, or source it from your
$HOME/.profile, or from /etc/profile.

David
Post by Roland Glenn McIntosh
test -f ./.bashrc && . ./.bashrc
It took me a second to figure out why .bashrc wasn't getting read (I thought it happened automatically by the shell) until I compared it to an older "working" cygwin install.
Is there a specific reason for that missing line in /etc/profile, or could it have been an oversight? I did notice that my redhat 7 system's /etc/profile doesn't seem to include such a line.
-rgm
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--
The Meaning of Life, the Universe and Everything:
10x + 5x - 35 = x + 7
Larry Hall (RFK Partners, Inc)
2002-03-26 19:26:41 UTC
Permalink
Wow. That was allot of discussion and conjecture on this topic. Did anyone
think of looking at the GNU bash documentation before posting?

http://www.lns.cornell.edu/public/COMP/info/bash/bashref_7.html#SEC65

Seems to me this answers the question quite well about where this kind of
check is recommended. And no post was required to get the information. ;-)

BTW, the check was removed from /etc/profile because bash is not the only
shell that reads that file.

Larry Hall ***@rfk.com
RFK Partners, Inc. http://www.rfk.com
838 Washington Street (508) 893-9779 - RFK Office
Holliston, MA 01746 (508) 893-9889 - FAX
Post by David Means
I believe that .bash_login, .bash_profile or .profile is the file
you're wanting to use in this instance.
man bash
{ snip }
When an interactive shell that is not a login shell is
started, bash reads and executes commands from ~/.bashrc, if
that file exists. This may be inhibited by using the --norc
option. The --rcfile file option will force bash to read
and execute commands from file instead of ~/.bashrc.
{ snip }
If you're realling wanting .bashrc to be sourced on a login-shell, then
you'll either need to set BASH_ENV=$HOME/.bashrc, or source it from your
$HOME/.profile, or from /etc/profile.
David
Post by Roland Glenn McIntosh
test -f ./.bashrc && . ./.bashrc
It took me a second to figure out why .bashrc wasn't getting read (I thought it happened automatically by the shell) until I compared it to an older "working" cygwin install.
Is there a specific reason for that missing line in /etc/profile, or could it have been an oversight? I did notice that my redhat 7 system's /etc/profile doesn't seem to include such a line.
-rgm
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--
10x + 5x - 35 = x + 7
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Gary R Van Sickle
2002-03-26 19:45:50 UTC
Permalink
Post by Roland Glenn McIntosh
My question is pretty simple: is editing the /etc/profile the
recommended way to get my ~/.bashrc file sourced?
I say: no.
Post by Roland Glenn McIntosh
And if not,
what is.
It should be noted that I found a message by Gary R. Van Sickle
suggesting that .bash_profile might be a better way to do things,
but this doesn't directly answer my question.
Yeah, well, that guy doesn't know what the heck he's talking about half the
time ;-). Here's how I have things set up, and I recommend it to everyone;
it seems to be the way bash was intended to work, and I can't see any flaws
in the scheme:

1. /etc/profile does not source any .bash* files. It does do a bunch of
things like "USER="`id -un`"", set the HOME var, and runs any scripts in
/etc/profile.d/ (not entirely sure what that's about), all of which was
setup by setup.exe.
2. .bashrc is empty.
3. .bash_profile sources .bashrc (just in case, for future use), and then
contains all my env var settings, aliases, etc.
4. PATH is *not* set in any of these files, but rather in the normal
Windows way (control panel on NT+, ??? on 9x).

So what you get with all this is:

1. PATH is always good, whether you're running cygwin apps from bash or the
Windows "command line", and regardless of how bash is invoked
(interactive/login or not).
2. When you start bash (interactively, your shell), it runs /etc/profile
and sets up the bare minimums and cd's to HOME.
3. After runing /etc/profile, bash looks for ~/.bash_profile and runs it to
set up your user stuff.
4. Subshells end up sourcing nothing (no BASH_ENV is defined anywhere), so
scripts run faster.
5. Interactive but non-login shells run an empty .bashrc. I don't know
when you'd get an interactive but non-login shell, but I haven't noticed any
problems to date.

--
Gary R. Van Sickle
Braemar Inc.
11481 Rupp Dr.
Burnsville, MN 55337


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/

Loading...