Red Hat Bugzilla – Bug 50678
removal of "-login" from bash invocation of Xsession causes environment variables to be lost
Last modified: 2007-04-18 12:35:24 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
Is bash your user shell?
The session is now launched as "exec -l $SHELL -c gnome-session"
(s/gnome-session/whatever you use/g).
exec -l $SHELL
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.
Tcsh is my login shell.
Obviously, if bash were my login shell, I wouldn't have this problem :-).
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
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.
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)
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
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...
exec -l $SHELL -c xterm -geometry 80x24-0-0
exec -l $SHELL -c "xterm -geometry 80x24-0-0"
Fixed in xinitrc in rawhide