* Re: [gentoo-user] man bash document doesn't match real life bash.
2007-09-19 15:03 [gentoo-user] man bash document doesn't match real life bash David Harel
@ 2007-09-19 13:23 ` Neil Bothwick
2007-09-19 13:43 ` Etaoin Shrdlu
2007-09-22 20:12 ` David Harel
2007-09-19 13:36 ` Albert Hopkins
1 sibling, 2 replies; 7+ messages in thread
From: Neil Bothwick @ 2007-09-19 13:23 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]
On Wed, 19 Sep 2007 17:03:16 +0200, David Harel wrote:
> I was surprised to find that in man bash the reference to initialization
> files is wrong. The bash manual says it reads initialization files from
> /etc/profile:
> FILES
> /bin/bash
> The bash executable
> /etc/profile
> The systemwide initialization file, executed for login
> shells
>
>
> Where real life uses /etc/bash/bashrc
> This part is taken from strace dump: strace bash -i
> open("/etc/bash/bashrc", O_RDONLY|O_LARGEFILE) = 3
It reads both, this is from /etc/profile
if [ -n "${BASH_VERSION}" ] ; then
# Newer bash ebuilds include /etc/bash/bashrc which will setup PS1
# including color. We leave out color here because not all
# terminals support it.
if [ -f /etc/bash/bashrc ] ; then
# Bash login shells run only /etc/profile
# Bash non-login shells run only /etc/bash/bashrc
# Since we want to run /etc/bash/bashrc regardless, we source it
# from here. It is unfortunate that there is no way to do
# this *after* the user's .bash_profile runs (without putting
# it in the user's dot-files), but it shouldn't make any
# difference.
. /etc/bash/bashrc
--
Neil Bothwick
"Come on! It's a whole new life out there!"
"Oh, no. Not another one!"
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] man bash document doesn't match real life bash.
2007-09-19 15:03 [gentoo-user] man bash document doesn't match real life bash David Harel
2007-09-19 13:23 ` Neil Bothwick
@ 2007-09-19 13:36 ` Albert Hopkins
1 sibling, 0 replies; 7+ messages in thread
From: Albert Hopkins @ 2007-09-19 13:36 UTC (permalink / raw
To: gentoo-user
On Wed, 2007-09-19 at 17:03 +0200, David Harel wrote:
> I was surprised to find that in man bash the reference to
> initialization
> files is wrong. The bash manual says it reads initialization files
> from
> /etc/profile:
> FILES
> /bin/bash
> The bash executable
> /etc/profile
> The systemwide initialization file, executed for login
> shells
Most bash installations have /etc/profile source /etc/bashrc. This is
not uncommon. You'll probably likely see the default ~/.bash_profile
source ~/.bashrc.
But it is sourcing /etc/profile else you wouldn't be getting half the
environment variables that you're getting.
-a
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] man bash document doesn't match real life bash.
2007-09-19 13:23 ` Neil Bothwick
@ 2007-09-19 13:43 ` Etaoin Shrdlu
2007-09-22 20:12 ` David Harel
1 sibling, 0 replies; 7+ messages in thread
From: Etaoin Shrdlu @ 2007-09-19 13:43 UTC (permalink / raw
To: gentoo-user
On Wednesday 19 September 2007, Neil Bothwick wrote:
> On Wed, 19 Sep 2007 17:03:16 +0200, David Harel wrote:
> > Where real life uses /etc/bash/bashrc
> > This part is taken from strace dump: strace bash -i
> > open("/etc/bash/bashrc", O_RDONLY|O_LARGEFILE) = 3
>
> It reads both, this is from /etc/profile
>
> if [ -n "${BASH_VERSION}" ] ; then
> # Newer bash ebuilds include /etc/bash/bashrc which will setup PS1
> # including color. We leave out color here because not all
> # terminals support it.
> if [ -f /etc/bash/bashrc ] ; then
> # Bash login shells run only /etc/profile
> # Bash non-login shells run only /etc/bash/bashrc
> # Since we want to run /etc/bash/bashrc regardless, we source
> it # from here. It is unfortunate that there is no way to do # this
> *after* the user's .bash_profile runs (without putting # it in the
> user's dot-files), but it shouldn't make any # difference.
> . /etc/bash/bashrc
It reads both, but the "Bash non-login shells run only /etc/bash/bashrc"
behavior is not documented in man bash.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gentoo-user] man bash document doesn't match real life bash.
@ 2007-09-19 15:03 David Harel
2007-09-19 13:23 ` Neil Bothwick
2007-09-19 13:36 ` Albert Hopkins
0 siblings, 2 replies; 7+ messages in thread
From: David Harel @ 2007-09-19 15:03 UTC (permalink / raw
To: gentoo-user
Hi,
I was surprised to find that in man bash the reference to initialization
files is wrong. The bash manual says it reads initialization files from
/etc/profile:
FILES
/bin/bash
The bash executable
/etc/profile
The systemwide initialization file, executed for login shells
Where real life uses /etc/bash/bashrc
This part is taken from strace dump: strace bash -i
open("/etc/bash/bashrc", O_RDONLY|O_LARGEFILE) = 3
I use bash from gentoo package:
$ equery belongs /usr/share/man/man1/bash.1.bz2
[ Searching for file(s) /usr/share/man/man1/bash.1.bz2 in *... ]
app-shells/bash-3.2_p17 (/usr/share/man/man1/bash.1.bz2)
$ equery belongs /bin/bash
[ Searching for file(s) /bin/bash in *... ]
app-shells/bash-3.2_p17 (/bin/bash)
--
Regards.
David Harel,
==================================
Home office +972 77 7657645
Fax: +972 77 7657645
Cellular: +972 54 4534502
Snail Mail: Amuka
D.N Merom Hagalil
13802
Israel
Email: hareldvd@ergolight-sw.com
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] man bash document doesn't match real life bash.
2007-09-19 13:23 ` Neil Bothwick
2007-09-19 13:43 ` Etaoin Shrdlu
@ 2007-09-22 20:12 ` David Harel
2007-09-23 3:19 ` Mrugesh Karnik
1 sibling, 1 reply; 7+ messages in thread
From: David Harel @ 2007-09-22 20:12 UTC (permalink / raw
To: gentoo-user
As Etaoin Shrdlu said, bash does not even start /etc/profile. Below grep
on strace output on bash:
$ grep profile /tmp/bash.trace
$
$ # My comment, it got nothing
$ grep bashrc /tmp/bash.trace
open("/etc/bash/bashrc", O_RDONLY|O_LARGEFILE) = 3
read(3, "# /etc/bash/bashrc\n#\n# This file"..., 2540) = 2540
open("/home/harel/.bashrc", O_RDONLY|O_LARGEFILE) = 3
Neil Bothwick wrote:
> On Wed, 19 Sep 2007 17:03:16 +0200, David Harel wrote:
>
>
>> I was surprised to find that in man bash the reference to initialization
>> files is wrong. The bash manual says it reads initialization files from
>> /etc/profile:
>> FILES
>> /bin/bash
>> The bash executable
>> /etc/profile
>> The systemwide initialization file, executed for login
>> shells
>>
>>
>> Where real life uses /etc/bash/bashrc
>> This part is taken from strace dump: strace bash -i
>> open("/etc/bash/bashrc", O_RDONLY|O_LARGEFILE) = 3
>>
>
> It reads both, this is from /etc/profile
>
> if [ -n "${BASH_VERSION}" ] ; then
> # Newer bash ebuilds include /etc/bash/bashrc which will setup PS1
> # including color. We leave out color here because not all
> # terminals support it.
> if [ -f /etc/bash/bashrc ] ; then
> # Bash login shells run only /etc/profile
> # Bash non-login shells run only /etc/bash/bashrc
> # Since we want to run /etc/bash/bashrc regardless, we source it
> # from here. It is unfortunate that there is no way to do
> # this *after* the user's .bash_profile runs (without putting
> # it in the user's dot-files), but it shouldn't make any
> # difference.
> . /etc/bash/bashrc
>
>
>
--
Regards.
David Harel,
==================================
Home office +972 77 7657645
Fax: +972 77 7657645
Cellular: +972 54 4534502
Snail Mail: Amuka
D.N Merom Hagalil
13802
Israel
Email: hareldvd@ergolight-sw.com
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] man bash document doesn't match real life bash.
2007-09-22 20:12 ` David Harel
@ 2007-09-23 3:19 ` Mrugesh Karnik
2007-09-23 8:35 ` Etaoin Shrdlu
0 siblings, 1 reply; 7+ messages in thread
From: Mrugesh Karnik @ 2007-09-23 3:19 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1716 bytes --]
> Neil Bothwick wrote:
> > On Wed, 19 Sep 2007 17:03:16 +0200, David Harel wrote:
> >> I was surprised to find that in man bash the reference to initialization
> >> files is wrong. The bash manual says it reads initialization files from
> >> /etc/profile:
> >> FILES
> >> /bin/bash
> >> The bash executable
> >> /etc/profile
> >> The systemwide initialization file, executed for login
> >> shells
> >>
> >>
> >> Where real life uses /etc/bash/bashrc
> >> This part is taken from strace dump: strace bash -i
> >> open("/etc/bash/bashrc", O_RDONLY|O_LARGEFILE) = 3
Hmmm. bash -i is not a login shell. An interactive shell doesn't
read /etc/profile if it's not a login shell.
From man bash:
``When bash is invoked as an interactive login shell, or as a
non-interactive shell with the --login option, it first reads and executes
commands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in
that order, and reads and executes commands from the first one that exists
and is readable. The --noprofile option may be used when the shell is started
to inhibit this behavior.
<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.''
--
----------------------------------------
Mrugesh Karnik
GPG Key 0xBA6F1DA8
Public key on http://wwwkeys.pgp.net
----------------------------------------
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] man bash document doesn't match real life bash.
2007-09-23 3:19 ` Mrugesh Karnik
@ 2007-09-23 8:35 ` Etaoin Shrdlu
0 siblings, 0 replies; 7+ messages in thread
From: Etaoin Shrdlu @ 2007-09-23 8:35 UTC (permalink / raw
To: gentoo-user
On Sunday 23 September 2007, Mrugesh Karnik wrote:
> From man bash:
>
> ``When bash is invoked as an interactive login shell, or as a
> non-interactive shell with the --login option, it first reads and
> executes commands from the file /etc/profile, if that file exists.
> After reading that file, it looks for ~/.bash_profile, ~/.bash_login,
> and ~/.profile, in that order, and reads and executes commands from
> the first one that exists and is readable. The --noprofile option may
> be used when the shell is started to inhibit this behavior.
>
> <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.''
And this last is the part that fails to mention that a non-login shell
will read /etc/bash/bashrc before ~/.bashrc, as the comments
inside /etc/bash/bashrc and David Harel say.
Ok, after closer inspection, it seems that the /etc/bash/ way is a
gentooism. Bash would normally define SYS_BASHRC and SYS_BASH_LOGOUT
as /etc/bash.bashrc and /etc/bash.bash_logout respectively, even though
it does not use them by default (they are commented in the sources).
Nearly all linux distros uncomment those definitions, thus making bash
use those files (see eg ubuntu). A gentoo patch, namely
bash-3.0-configs.patch, changes those into /etc/bash/bashrc
and /etc/bash/bash_logout. See bug #26952 (esp. from comment #52) and
bug #90488 for further details. Note that gentoo applies the patch
regardless of the vanilla USE flag.
So, it seems that, after all, the standard man page is correct, but, in
gentoo, it probably should be patched to reflect the way things work in
gentoo. Not sure whether this is enough to be worth a bug report?
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-09-23 8:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-19 15:03 [gentoo-user] man bash document doesn't match real life bash David Harel
2007-09-19 13:23 ` Neil Bothwick
2007-09-19 13:43 ` Etaoin Shrdlu
2007-09-22 20:12 ` David Harel
2007-09-23 3:19 ` Mrugesh Karnik
2007-09-23 8:35 ` Etaoin Shrdlu
2007-09-19 13:36 ` Albert Hopkins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox