2015-03-03
The latest xterm
versions mangle $SHELL
in annoying ways
As of patch #301 (and
with changes since then), the canonical version of xterm
has some
unfortunate behavior changes surrounding the $SHELL
environment
variable and how xterm
interacts with it. The full details are
in the xterm
manpage
in the OPTIONS
section, but the summary is that xterm
now clears
or changes $SHELL
if the $SHELL
value is not in /etc/shells
,
and sometimes even if it is. As far as I can tell, the decision
tree goes like this:
- if
xterm
is (explicitly) running something that is in/etc/shells
(as 'xterm /some/thing
', not 'xterm -e /some/thing
'),$SHELL
will be rewritten to that thing. - if
xterm
is running anything (including running$SHELL
itself via being invoked as just 'xterm
') and$SHELL
is not in/etc/shells
but your login shell is,$SHELL
will be reset to your login shell. - otherwise
$SHELL
will be removed from the environment, resulting in a shell environment with$SHELL
unset. This happens even if you run plain 'xterm
' and soxterm
is running$SHELL
.
It is difficult for me to summarize concisely how wrong this is and
how many ways it can cause problems. For a start, this is a misuse
of /etc/shells
, per my entry on what it is and isn't;
/etc/shells
is in no way a complete list of all of the shells (or
all of the good shells) that are in use on the system. You cannot
validate the contents of $SHELL
against /etc/shells
because
that is not what /etc/shells
is there for.
This xterm
change causes significant problems for anyone with
their shell set to something that is not in /etc/shells
, anyone
using an alternate personal shell (which
is not in /etc/shells
for obvious reasons), any program that
assumes $SHELL
is always set (historically a safe assumption),
and any environment that assumes $SHELL
is not reset when set to
something non-standard such as a captive or special purpose 'shell'.
(Not all versions of chsh
restrict you to what's in /etc/shells
,
for that matter; some will let you set other things if you really
ask them to.)
If you fall into one or more of these categories and you use xterm
,
you're going to need to change your environment at some point.
Unfortunately it seems unlikely that this change will be reverted, so
if your version of Unix updates xterm
at all you're going to have it
sooner or later (so far only a few Linux distributions are recent enough
to have it).
PS: Perhaps this should be my cue to switch to urxvt
. However my
almost-default configuration of it is still just enough different
from xterm
to be irritating for me, although maybe I could fix
that with enough customization work. For example, I really want
its double-click selection behavior to exactly match xterm
because
that's what my reflexes expect and demand by now. See also.
PPS: Yes, I do get quite irritated at abrupt incompatible changes in the behavior of long-standing Unix programs, at least when they affect me.