Re: PATH value doesn't get updated

2008-05-18 Thread Peter Volkov
В Пнд, 12/05/2008 в 17:02 -0600, Bob Proulx пишет:

 The $0 is the name used to invoke the shell.  If it starts with a '-'
 then this is used to instruct the shell that it is a login shell.  The
 second variable $- is the flags set to the shell.  The 'i' for
 interactive should be in there.

Actually that's not exactly true. It's possible to start bash as login
shell but - will be absent. Quoting relevant part of manual:

A _login_ shell is one whose first character of argument zero is `-',
or one invoked with the `--login' option.

Better way to check if shell is login is:

 $ shopt | grep login_shell
login_shell on

-- 
Peter.





Re: PATH value doesn't get updated

2008-05-18 Thread Bernd Eggink

Peter Volkov schrieb:



Better way to check if shell is login is:

 $ shopt | grep login_shell
login_shell on


You don't even have to call an external program:

[[ $(shopt -p login_shell) == *-s* ]]

Regards,
Bernd

--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de




Re: PATH value doesn't get updated

2008-05-18 Thread Bob Proulx
Peter Volkov wrote:
 Bob Proulx пишет:
  The $0 is the name used to invoke the shell.  If it starts with a '-'
  then this is used to instruct the shell that it is a login shell.  The
  second variable $- is the flags set to the shell.  The 'i' for
  interactive should be in there.
 
 Actually that's not exactly true. It's possible to start bash as login
 shell but - will be absent. Quoting relevant part of manual:
 
 A _login_ shell is one whose first character of argument zero is `-',
 or one invoked with the `--login' option.

Yes.  To be pedantic about things I didn't say those were the only
ways and I did also mention --login in my mail.

 Better way to check if shell is login is:
 
  $ shopt | grep login_shell
 login_shell on

That will tell if bash *is* a login shell but that wasn't the question
that I was asking.  I was asking if bash was being instructed to be a
login shell using normal login conventions.  Seeing that $0 doesn't
start with a dash says that it wasn't.  Therefore bash is behaving
normally.

If you explicitly log into the host again such as with 'ssh localhost'
then you should see that sshd sets $0 to start with a dash.  Then bash
knows that it is a login shell.  Then bash sources the login
environment files.

It is just the unfortunate default configuration of GDM/KDM that
doesn't start up X sessions with some parent shell as a login shell
and therefore (by default) .bash_profile isn't getting sourced.  The
scripts don't cause personal environments to be sourced.  This is even
an FAQ for KDE.

Different GNU/Linux distros have taken steps to address this issue by
different methods and some have done nothing sticking to the default
behavior.  Debian and Ubuntu have not modified this and are using the
default behavior while Red Hat and SuSE have both taken *different*
actions to make login environments be sourced.  Plus there are several
classic Unix environments other than the new GNU/Linux ones that do
things the old ways.  Having many possibilities makes this a messy
problem to describe, document and address.

Bob




Re: PATH value doesn't get updated

2008-05-14 Thread Bob Proulx
Carl Wenrich wrote:
 I just log into the box that appears on the standard ubuntu
 startup. I enter my username and password, then the desktop comes
 up.

You are using GDM (GNOME Display Manager) then.  In which case it
won't automatically start up shells as login shells.  It is a quirk of
how the X session is started.

 I see now that the .bash_profile isn't being sourced (I thought it
 was according to what I've been able to pick up on the web). If I
 source it manually, the $PATH gets updated.

It would be sourced if you were to log into your machine with ssh or
the text console.

 Why does ubuntu provide the .bash_profile when a user is created,
 and then not source it when the system starts up? And since it
 doesn't, what do I change to make it happen?

That is a long story.  If you are interested you can read some
archeology that has been done on this problem at this following URL.
Note that even though the bug has been closed that it isn't fixed.  I
am hoping to getting back to driving on it again one day.

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=250765

Red Hat's solution seems to be the best.  But it would require you to
patch your system files.

I recommend creating a $HOME/.xsession file, making it executable,
with the following contents.  Make sure it is executable.

  #!/bin/bash --login
  exec x-session-manager  # Debian specific generic alternative.
  #exec gnome-session
  #exec startkde
  #exec fvwm2

  chmod a+x ~/.xsession

This invokes bash as a login shell and then invokes the X session
manager.  x-session-manager is an alternative in Debian and will
automatically track the best installed manager.  But others may be
selected explicitly.  (I use fvwm. :-)

This is off topic for the bash list.  If you have further problems the
Ubuntu user mailing list would probably be your best place for more
help about how to configure your Ubuntu system.  If you contact me
offlist I would continue to help you if you have problems with setting
up an ~/.xsession file.

Bob




PATH value doesn't get updated

2008-05-12 Thread carlwenrich

I put this in my .bash_profile:

PATH=$PATH:/opt/lampp/bin
export PATH

but when I echo $PATH it doesn't include the /opt/lampp/bin.
-- 
View this message in context: 
http://www.nabble.com/PATH-value-doesn%27t-get-updated-tp17189469p17189469.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





Re: PATH value doesn't get updated

2008-05-12 Thread Bob Proulx
carlwenrich wrote:
 I put this in my .bash_profile:
 
 PATH=$PATH:/opt/lampp/bin
 export PATH
 
 but when I echo $PATH it doesn't include the /opt/lampp/bin.

The .bash_profile is sourced by bash when it is invoked as an
interactive login shell.  Therefore you would need to log in after
having made that change in order for bash to read the file and the
effect to be seen.  Did you log in after having made that change?  Was
bash invoked as an interactive login shell so that it would read that
file?

  echo $0
  echo $-

Bob




Re: PATH value doesn't get updated

2008-05-12 Thread Carl Wenrich
Yes. I (1) made the change to .bash_profile, then (2) restarted the machine, 
then (3) logged in again. When I echo $PATH the /opt/lampp/bin is not included.

Bob Proulx [EMAIL PROTECTED] wrote: carlwenrich wrote:
 I put this in my .bash_profile:
 
 PATH=$PATH:/opt/lampp/bin
 export PATH
 
 but when I echo $PATH it doesn't include the /opt/lampp/bin.

The .bash_profile is sourced by bash when it is invoked as an
interactive login shell.  Therefore you would need to log in after
having made that change in order for bash to read the file and the
effect to be seen.  Did you log in after having made that change?  Was
bash invoked as an interactive login shell so that it would read that
file?

  echo $0
  echo $-

Bob



Re: PATH value doesn't get updated

2008-05-12 Thread Bob Proulx
Carl Wenrich wrote:
 Bob Proulx wrote:
  Did you log in after having made that change?  Was bash invoked as
  an interactive login shell so that it would read that file?
  
echo $0
echo $-

 Yes. I (1) made the change to .bash_profile, then (2) restarted the
 machine, then (3) logged in again. When I echo $PATH the
 /opt/lampp/bin is not included.

That second question was also very important.  Without that
information I don't know if I should suggest one action or a different
action.

  Was bash invoked as an interactive login shell so that it would read
  that file?

The way I tell is by running those two commands that I suggested
running.  What do you get for the following two commands?

  echo $0
  echo $-

The $0 is the name used to invoke the shell.  If it starts with a '-'
then this is used to instruct the shell that it is a login shell.  The
second variable $- is the flags set to the shell.  The 'i' for
interactive should be in there.

Example: NOT a login shell, will NOT source .bash_profile:

  $ echo $0
  bash
  $ echo $-
  himBHP
  $

Example: Yes, a login shell:

  $ echo $0
  -bash
  $ echo $-
  himBHP
  $

And of course the bash -l and --login options will override this
default behavior.

If it is not a login shell then to suggest improvements it would be
necessary to know the type of system you are using and how you are
logging into it.  There are many possibilities and I can't guess which
one you might be using.  You didn't say in your messages.

By the way... It is not necessary to restart your system.  That is way
too much.  Simply log in again to have profile file changes take
effect.

Bob




Re: PATH value doesn't get updated

2008-05-12 Thread Carl Wenrich
echo $0 gives me bash
echo $- gives me himBH

Bob Proulx [EMAIL PROTECTED] wrote: Carl Wenrich wrote:
 Bob Proulx wrote:
  Did you log in after having made that change?  Was bash invoked as
  an interactive login shell so that it would read that file?
  
echo $0
echo $-

 Yes. I (1) made the change to .bash_profile, then (2) restarted the
 machine, then (3) logged in again. When I echo $PATH the
 /opt/lampp/bin is not included.

That second question was also very important.  Without that
information I don't know if I should suggest one action or a different
action.

  Was bash invoked as an interactive login shell so that it would read
  that file?

The way I tell is by running those two commands that I suggested
running.  What do you get for the following two commands?

  echo $0
  echo $-

The $0 is the name used to invoke the shell.  If it starts with a '-'
then this is used to instruct the shell that it is a login shell.  The
second variable $- is the flags set to the shell.  The 'i' for
interactive should be in there.

Example: NOT a login shell, will NOT source .bash_profile:

  $ echo $0
  bash
  $ echo $-
  himBHP
  $

Example: Yes, a login shell:

  $ echo $0
  -bash
  $ echo $-
  himBHP
  $

And of course the bash -l and --login options will override this
default behavior.

If it is not a login shell then to suggest improvements it would be
necessary to know the type of system you are using and how you are
logging into it.  There are many possibilities and I can't guess which
one you might be using.  You didn't say in your messages.

By the way... It is not necessary to restart your system.  That is way
too much.  Simply log in again to have profile file changes take
effect.

Bob



Re: PATH value doesn't get updated

2008-05-12 Thread Bob Proulx
Carl Wenrich wrote:
 echo $0 gives me bash
 echo $- gives me himBH

Then bash hasn't been invoked as a login shell and therefore isn't
instructed to source the .bash_profile.

 If it is not a login shell then to suggest improvements it would be
 necessary to know the type of system you are using and how you are
 logging into it.  There are many possibilities and I can't guess which
 one you might be using.  You didn't say in your messages.

You have yet to say how are you are logging into your machine.  There
are many possibilities and without information it is impossible to
guess.

In the hope that it is helpful I will take a shot in the dark...

On my HP-UX machine I log into the text console.  This gives me a
login shell that sources my .bash_profile.  I then start X11 using
'xinit' which inherits all of the exported variables.  On my Debian
GNU/Linux machine I log in using GDM.  Because logging in with XDM, or
GDM, or KDM doesn't start a login shell I need to tell it this
explicitly.  I use an executable ~/.xsession file.  In it I explicitly
tell bash that it is a login shell which causes my .bash_profile to be
sourced.  Subsequent shells inherit the environment.  This is what I
use in my personal configuration:

  #!/bin/bash --login
  # exec x-session-manager
  # exec gnome-session
  # exec startkde
  exec fvwm2

Red Hat solves this problem in a better way by invoking the user
session as a login shell from the system X start up scripts.  By doing
it that way the user doesn't need to worry about it.  Last time I
checked SuSE was a problem because it forced sourcing of the
$HOME/.bash_profile (or was it .profile?)  regardless of the user
shell and then redirected all errors to /dev/null effectively ignoring
them.  Other systems will be similarly different.

In any case I believe you have an answer to your question about why
your ~/.bash_profile wasn't being sourced.  It wasn't being sourced
because your shell isn't invoked as a login shell and therefore
shouldn't source it.

Good luck!

Bob




Re: PATH value doesn't get updated

2008-05-12 Thread Carl Wenrich
I just log into the box that appears on the standard ubuntu startup. I enter my 
username and password, then the desktop comes up.

I see now that the .bash_profile isn't being sourced (I thought it was 
according to what I've been able to pick up on the web). If I source it 
manually, the $PATH gets updated.

Why does ubuntu provide the .bash_profile when a user is created, and then not 
source it when the system starts up? And since it doesn't, what do I change to 
make it happen?

Bob Proulx [EMAIL PROTECTED] wrote: Carl Wenrich wrote:
 echo $0 gives me bash
 echo $- gives me himBH

Then bash hasn't been invoked as a login shell and therefore isn't
instructed to source the .bash_profile.

 If it is not a login shell then to suggest improvements it would be
 necessary to know the type of system you are using and how you are
 logging into it.  There are many possibilities and I can't guess which
 one you might be using.  You didn't say in your messages.

You have yet to say how are you are logging into your machine.  There
are many possibilities and without information it is impossible to
guess.

In the hope that it is helpful I will take a shot in the dark...

On my HP-UX machine I log into the text console.  This gives me a
login shell that sources my .bash_profile.  I then start X11 using
'xinit' which inherits all of the exported variables.  On my Debian
GNU/Linux machine I log in using GDM.  Because logging in with XDM, or
GDM, or KDM doesn't start a login shell I need to tell it this
explicitly.  I use an executable ~/.xsession file.  In it I explicitly
tell bash that it is a login shell which causes my .bash_profile to be
sourced.  Subsequent shells inherit the environment.  This is what I
use in my personal configuration:

  #!/bin/bash --login
  # exec x-session-manager
  # exec gnome-session
  # exec startkde
  exec fvwm2

Red Hat solves this problem in a better way by invoking the user
session as a login shell from the system X start up scripts.  By doing
it that way the user doesn't need to worry about it.  Last time I
checked SuSE was a problem because it forced sourcing of the
$HOME/.bash_profile (or was it .profile?)  regardless of the user
shell and then redirected all errors to /dev/null effectively ignoring
them.  Other systems will be similarly different.

In any case I believe you have an answer to your question about why
your ~/.bash_profile wasn't being sourced.  It wasn't being sourced
because your shell isn't invoked as a login shell and therefore
shouldn't source it.

Good luck!

Bob