Bug 50678 - removal of "-login" from bash invocation of Xsession causes environment variables to be lost
removal of "-login" from bash invocation of Xsession causes environment varia...
Product: Red Hat Raw Hide
Classification: Retired
Component: tcsh (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Eido Inoue
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2001-08-01 20:42 EDT by Jonathan Kamens
Modified: 2007-04-18 12:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-08-21 14:01:10 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jonathan Kamens 2001-08-01 20:42:15 EDT
Run "bash -c set > /tmp/non-login" and "bash -login -c set > /tmp/login". 
Then run "diff /tmp/non-login /tmp/login".  You will see that when bash is
run as a login shell, it sets various variables that it doesn't set
otherwise, and it changes the settings of some other variables.  The most
interesting of these is MAIL, which isn't set at all when bash isn't a
login shell.  As a result of this, the recent change from "#!/bin/bash
-login" to "#!/bin/bash" in /etc/X11/xdm/Xsession has caused the default
setting of the MAIL environment variable to be lost.

It needs to be put back somewhere.  Perhaps it doesn't belong in xinitrc --
perhaps it belongs in something in /etc/profile.d.  But it shouldn't just
Comment 1 Havoc Pennington 2001-08-01 23:54:34 EDT
Is bash your user shell?

The session is now launched as "exec -l $SHELL -c gnome-session"
(s/gnome-session/whatever you use/g).

Try this:
 unset MAIL
 exec -l $SHELL 
 echo $MAIL

For me MAIL is then set.

I'm not at work now, but tomorrow I'll check a test machine to see if $MAIL is
set for the entire X session as it should be.
If bash is not your shell, the problem may be that /etc/csh.login does not set
up $MAIL. Or an alternative solution is to re-add the --login at the top of
Xsession, but leave the exec -l part later in Xsession as well. This would then
make a login tcsh shell into a child of a login bash shell, so it would inherit
environment variables. I tend to think this is broken though, fixing
/etc/csh.login is likely more appropriate.
Comment 2 Jonathan Kamens 2001-08-02 06:41:18 EDT
Tcsh is my login shell.

Obviously, if bash were my login shell, I wouldn't have this problem :-).
Comment 3 Havoc Pennington 2001-08-02 09:38:58 EDT
So we should either re-add the --login for now (but leave the exec -l $SHELL
bit) as a short-term hack, or reassign to tcsh and be sure we sync /etc/profile
to /etc/csh.login. I guess should reassign to tcsh even if we add the --login hack 
for now.
Comment 4 Mike A. Harris 2001-08-08 11:39:56 EDT
After prior discussion with hp, --login stays as it is "the right thing",
reassigning to tcsh.  tcsh should mirror bash's startup more WRT
the login scripts.
Comment 5 Havoc Pennington 2001-08-08 12:03:52 EDT
Hang on, --login isn't the right thing, it's just a workaround for tcsh not 
having what it should in csh.login. (It's fine to put --login back for this
release, just let's remember to take it out again for 8.0)
Comment 6 Mike A. Harris 2001-08-08 12:25:04 EDT
Sorry hp, bad wording on my part.  What I meant was, -login is gone
now, and stays gone.  I was convinced in our emails that it was
correct, but may cause odd problems in other broken things, now we
know that it is not far reaching, and so they aren't major issues.
I plan on keeping it without the -login to bash.  Sorry for the bad
explanation above..

Fix tcsh is the solution.  In the past, using tcsh out of the box
wouldn't have worked correct anyway, so leaving the new way doesn't
lose anything IMHO, but gains the correct way of doing this at least
in xinitrc.  Now when tcsh is fixed (a few hours work really), all
should be well for tcsh users.  Other shells aren't very important
such as ksh/whatever IMHO as they are virtually unused in the big
picture.  That is another bug report if true...
Comment 7 Jim Radford 2001-08-20 13:48:54 EDT
       exec -l $SHELL -c xterm -geometry 80x24-0-0

Should be

       exec -l $SHELL -c "xterm -geometry 80x24-0-0"
Comment 8 Mike A. Harris 2001-08-21 14:01:05 EDT
Fixed in xinitrc in rawhide

Note You need to log in before you can comment on or make changes to this bug.