+2008-10-15 Paolo Bonzini <bonzini@gnu.org>
+
+ Assume a (possibly buggy) `unset' is present after a
+ `better shell' was found.
+ * lib/autoconf/general.m4 (_AC_CACHE_DUMP): Use AS_UNSET.
+ * lib/autoconf/programs.m4 (AC_PROG_SED): Use AS_UNSET.
+ * lib/m4sugar/m4sh.m4 (_AS_UNSET_PREPARE): Provide $as_unset as an
+ alias for AS_UNSET, for backwards compatibility.
+ (_AS_DETECT_BETTER_SHELL): Set BASH_ENV and ENV to /dev/null in case
+ the shell does not support unset.
+ (_AS_SHELL_SANITIZE): Work around Bash 2.01 bugs. Unset BASH_ENV.
+ (AS_INIT, _AS_PREPARE, AS_PREPARE): Call it.
+ (AS_UNSET): Assume it is there but it might fail if the variable is
+ not set. Use it throughout instead of $as_unset.
+
2008-10-15 Paolo Bonzini <bonzini@gnu.org>
Turn AS_SHELL_SANITIZE into a for-Libtool-only wrapper.
done
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
- done
+ [# We cannot yet assume a decent shell, so we have to provide a
+ # neutralization value for shells without unset; and this also
+ # works around shells that cannot unset nonexistent variables.
+ BASH_ENV=/dev/null
+ ENV=/dev/null
+ (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}])
_AS_TEST_PREPARE
_AS_TR_CPP_PREPARE
_AS_TR_SH_PREPARE
+_AS_UNSET_PREPARE
])
# AS_PREPARE
AS_REQUIRE([_AS_TEST_PREPARE])
AS_REQUIRE([_AS_TR_CPP_PREPARE])
AS_REQUIRE([_AS_TR_SH_PREPARE])
+AS_REQUIRE([_AS_UNSET_PREPARE])
])
# xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
#
m4_define([AS_REQUIRE_SHELL_FN],
-[_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
-AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
+[AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
{
$2
}], m4_default_quoted([$3], [M4SH-INIT-FN]))])
_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
AS_EXIT
fi
-# Work around bugs in pre-3.0 UWIN ksh.
-for as_var in ENV MAIL MAILPATH
-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+# Unset variables that we do not need and cause bugs (e.g. in pre-3.0 UWIN ksh).
+# But do not cause bugs in bash 2.01; the "|| exit 1" suppresses any
+# "Segmentation fault" message there. '((' could trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset && dnl
+ ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
export LANGUAGE
# CDPATH.
-$as_unset CDPATH
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
])# _AS_SHELL_SANITIZE
[m4_provide([AS_INIT])
_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
_AS_DETECT_BETTER_SHELL
+_AS_UNSET_PREPARE
])])
# _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.
+# Define $as_unset to execute AS_UNSET, for backwards compatibility
+# with older versions of M4sh.
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_func_unset ()
+{
+ AS_UNSET([$[1]])
+}
+as_unset=as_func_unset
])
-# AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
-# --------------------------------------------------
-# Try to unset the env VAR, otherwise set it to
-# VALUE-IF-UNSET-NOT-SUPPORTED. `as_unset' must have been computed.
+# AS_UNSET(VAR)
+# -------------
+# 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; }])
+[{ AS_LITERAL_IF([$1], [], [eval ])$1=; unset $1;}])
# Let's go!
m4_divert_pop([KILL])[]dnl
m4_divert_push([BODY])[]dnl
+_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
+AS_REQUIRE([_AS_UNSET_PREPARE])dnl For backwards compatibility.
])