]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Assume a (possibly buggy) `unset' is present after a `better shell' was found.
authorPaolo Bonzini <bonzini@gnu.org>
Tue, 14 Oct 2008 05:16:48 +0000 (07:16 +0200)
committerPaolo Bonzini <bonzini@gnu.org>
Wed, 15 Oct 2008 14:05:07 +0000 (16:05 +0200)
* 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.

ChangeLog
lib/autoconf/general.m4
lib/autoconf/programs.m4
lib/m4sugar/m4sh.m4

index f4e91fa9a03d7636b03ea79abf974aa94eb756a6..5c3ec43528bccfc1aa7bdc4fd86fd80ad939017e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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.
index 986b7af4f7605c19a9b25a44bcede0b3a1cbde08..beb310459641292a9cf154357606ccb5c9340b5a 100644 (file)
@@ -1894,7 +1894,7 @@ m4_define([_AC_CACHE_DUMP],
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) $as_unset $ac_var ;;
+      *) AS_UNSET([$ac_var]) ;;
       esac ;;
     esac
   done
index 63f8a13f57044e9635d6628e0eefffd6d09568a5..45a74b5c4da0547b4696ad1ddf0c21d8413207c6 100644 (file)
@@ -894,7 +894,7 @@ AC_DEFUN([AC_PROG_SED],
        ac_script="$ac_script$as_nl$ac_script"
      done
      echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
-     $as_unset ac_script || ac_script=
+     AS_UNSET([ac_script])
      _AC_PATH_PROGS_FEATURE_CHECK(SED, [sed gsed],
        [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
                ["$ac_path_SED" -f conftest.sed])])])
index 1ebf1be5bb3eddc7ccd01d5a1d6102971142ef5a..64cc8db294950b493eecebfc0ebedfa87f306257 100644 (file)
@@ -224,9 +224,12 @@ dnl Remove any tests from suggested that are also required
       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+"$[@]"}])
 
@@ -270,6 +273,7 @@ _AS_MKDIR_P_PREPARE
 _AS_TEST_PREPARE
 _AS_TR_CPP_PREPARE
 _AS_TR_SH_PREPARE
+_AS_UNSET_PREPARE
 ])
 
 # AS_PREPARE
@@ -290,6 +294,7 @@ AS_REQUIRE([_AS_MKDIR_P_PREPARE])
 AS_REQUIRE([_AS_TEST_PREPARE])
 AS_REQUIRE([_AS_TR_CPP_PREPARE])
 AS_REQUIRE([_AS_TR_SH_PREPARE])
+AS_REQUIRE([_AS_UNSET_PREPARE])
 ])
 
 
@@ -315,8 +320,7 @@ m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)), 1,
 # 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]))])
@@ -391,7 +395,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
@@ -417,9 +420,12 @@ if test ! -f "$as_myself"; then
   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='> '
@@ -432,7 +438,7 @@ LANGUAGE=C
 export LANGUAGE
 
 # CDPATH.
-$as_unset CDPATH
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 ])# _AS_SHELL_SANITIZE
 
 
@@ -446,6 +452,7 @@ m4_provide_if([AS_INIT], [],
 [m4_provide([AS_INIT])
 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
 _AS_DETECT_BETTER_SHELL
+_AS_UNSET_PREPARE
 ])])
 
 
@@ -526,27 +533,24 @@ fi
 
 # _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;}])
 
 
 
@@ -1720,4 +1724,6 @@ m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
 # 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.
 ])