[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] modernize AS_UNSET a bit
From: |
Paolo Bonzini |
Subject: |
[PATCH] modernize AS_UNSET a bit |
Date: |
Tue, 14 Oct 2008 07:16:48 +0200 |
This patch modernizes a bit what we assume about unset. In particular,
we assume that unset exists but might fail if the variable is not present.
We also assume that the user won't unset MAIL and MAILCHECK; we do that
in m4sh's initialization in a way that won't upset Bash 2.01 (did not
test it though, I don't have that shell).
This in turn removes the need for _AS_UNSET_PREPARE.
2008-10-14 Paolo Bonzini <address@hidden>
* lib/m4sugar/m4sh.m4 (_AS_UNSET_PREPARE): Eliminate.
(AS_SHELL_SANITIZE): Work around Bash 2.01 bugs.
(AS_UNSET): Assume it is there but it might fail if the variable is
not there. Use it throughout instead of $as_unset.
---
lib/m4sugar/m4sh.m4 | 40 +++++++++++----------------------------
1 files changed, 12 insertions(+), 28 deletions(-)
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 9c1af0f..7e35313 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -187,8 +187,7 @@ m4_set_add([_AS_DETECT_SUGGESTED_BODY],
# <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
#
m4_defun_once([_AS_DETECT_BETTER_SHELL],
-[AS_REQUIRE([_AS_UNSET_PREPARE], , [M4SH-SANITIZE])dnl
-m4_append([_AS_CLEANUP], [m4_divert_text([M4SH-SANITIZE], [
+[m4_append([_AS_CLEANUP], [m4_divert_text([M4SH-SANITIZE], [
if test "x$CONFIG_SHELL" = x; then
dnl Remove any tests from suggested that are also required
m4_set_foreach([_AS_DETECT_SUGGESTED_BODY], [AS_snippet],
@@ -227,7 +226,7 @@ dnl Remove any tests from suggested that are also required
AS_IF([test "x$CONFIG_SHELL" != x],
[for as_var in BASH_ENV ENV
- do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ do AS_UNSET([$as_var])
done
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$as_myself" ${1+"address@hidden"}])
@@ -428,7 +427,6 @@ AS_BOURNE_COMPATIBLE
_AS_CR_PREPARE
_AS_ECHO_PREPARE
_AS_PATH_SEPARATOR_PREPARE
-_AS_UNSET_PREPARE
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
@@ -454,9 +452,11 @@ if test ! -f "$as_myself"; then
AS_EXIT
fi
-# Work around bugs in pre-3.0 UWIN ksh.
+# Work around bugs in pre-3.0 UWIN ksh. But do not cause bugs in bash 2.01.
+# The "|| exit 1" suppresses any "Segmentation fault" message there.
+# Avoid 'if ((', as that triggers a bug in pdksh 5.2.14.
for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+do ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
@@ -469,7 +467,7 @@ LANGUAGE=C
export LANGUAGE
# CDPATH.
-$as_unset CDPATH
+AS_UNSET([CDPATH])
])# AS_SHELL_SANITIZE
@@ -548,29 +546,13 @@ fi
])# AS_IF
-# _AS_UNSET_PREPARE
-# -----------------
-# AS_UNSET depends upon $as_unset: compute it.
-# Use MAIL to trigger a bug in Bash 2.01;
-# the "|| exit" suppresses the resulting "Segmentation fault" message.
-# Avoid 'if ((', as that triggers a bug in pdksh 5.2.14.
-m4_defun([_AS_UNSET_PREPARE],
-[# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-])
-
-
-# AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
+# AS_UNSET(VAR)
# --------------------------------------------------
-# Try to unset the env VAR, otherwise set it to
-# VALUE-IF-UNSET-NOT-SUPPORTED. `as_unset' must have been computed.
+# Unset the env VAR, working around shells that do not allow unsetting
+# a variable that is not already set. You should not unset MAIL and
+# MAILCHECK, as that triggers a bug in Bash 2.01.
m4_defun([AS_UNSET],
-[AS_REQUIRE([_AS_UNSET_PREPARE])dnl
-$as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
+[{ unset $1 >/dev/null 2>&1 || :;}])
--
1.5.5
- [PATCH] modernize AS_UNSET a bit,
Paolo Bonzini <=