Re: [gentoo-user] man bash document doesn't match real life bash.

2007-09-23 Thread Etaoin Shrdlu
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?
-- 
[EMAIL PROTECTED] mailing list



Re: [gentoo-user] man bash document doesn't match real life bash.

2007-09-22 Thread David Harel
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:  [EMAIL PROTECTED]


-- 
[EMAIL PROTECTED] mailing list



Re: [gentoo-user] man bash document doesn't match real life bash.

2007-09-22 Thread Mrugesh Karnik
 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



signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] man bash document doesn't match real life bash.

2007-09-19 Thread Neil Bothwick
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!


signature.asc
Description: PGP signature


Re: [gentoo-user] man bash document doesn't match real life bash.

2007-09-19 Thread Etaoin Shrdlu
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.
-- 
[EMAIL PROTECTED] mailing list



Re: [gentoo-user] man bash document doesn't match real life bash.

2007-09-19 Thread Albert Hopkins
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

-- 
[EMAIL PROTECTED] mailing list