[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `unset' and bash...
From: |
Paul Eggert |
Subject: |
Re: `unset' and bash... |
Date: |
Sun, 03 Sep 2006 12:45:45 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
> OK to install the patch below? Or should we just go all the way and
> recommend the exact code that is _AS_UNSET_PREPARE?
I guess the latter, though it's a close call -- does anybody still
use Bash 2.01?
> I don't quite understand the Bash 2.01 bug; was that setting MAIL to
> something, or unsetting MAIL that triggered the segfault?
It was unsetting mail, plus unsetting MAILCHECK.
You can see Bob Dowling's 1998 bug report
<http://groups.google.com/group/gnu.bash.bug/msg/5a41781550c61d62>
and I also vaguely remember running into the problem.
I installed this somewhat-different change. The newer Bash bug was
fixed after 2.05a came out, according to its changes file.
2006-09-03 Paul Eggert <address@hidden>
* doc/autoconf.texi (Limitations of Builtins): Document 'unset'
bugs of Bash 2.01 and 2.05a. Problem report and initial patch by
Ralf Wildenhues.
--- doc/autoconf.texi.~1.1076.~ 2006-09-01 16:15:32.000000000 -0700
+++ doc/autoconf.texi 2006-09-03 12:38:17.000000000 -0700
@@ -12850,21 +12850,27 @@ for @command{true}.
@item @command{unset}
@c ------------------
@prindex @command{unset}
-You cannot assume the support of @command{unset}. Nevertheless, because
+In some nonconforming shells (e.g., Bash 2.05a), @code{unset FOO} fails
+when @code{FOO} is not set. Also, Bash 2.01 mishandles @code{unset
+MAIL} in some cases and dumps core.
+
+A few ancient shells lack @command{unset} entirely. Nevertheless, because
it is extremely useful to disable embarrassing variables such as
@code{PS1}, you can test for its existence and use
it @emph{provided} you give a neutralizing value when @command{unset} is
not supported:
address@hidden
-if (unset FOO) >/dev/null 2>&1; then
address@hidden
+# "|| exit" suppresses any "Segmentation fault" message.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
unset=unset
else
unset=false
fi
$unset PS1 || PS1='$ '
address@hidden example
address@hidden smallexample
address@hidden
@xref{Special Shell Variables}, for some neutralizing values. Also, see
@ref{Limitations of Builtins}, documentation of @command{export}, for
the case of environment variables.