]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* m4sh.m4 (AS_EXIT): New macro that exits and makes sure that $?
authorPavel Roskin <proski@gnu.org>
Mon, 30 Oct 2000 12:29:36 +0000 (12:29 +0000)
committerPavel Roskin <proski@gnu.org>
Mon, 30 Oct 2000 12:29:36 +0000 (12:29 +0000)
        is set correctly within the exit trap.
        (AS_TMPDIR): Use it.
        * acgeneral.m4 (AC_MSG_ERROR): Likewise,

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

index 6215da98d5c0deeab137786f76b695a2810a50e5..e4cf52600eb3a1f23cba091aca6d7ea8ce3e60df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-10-30  Pavel Roskin  <proski@gnu.org>
+
+       * m4sh.m4 (AS_EXIT): New macro that exits and makes sure that $?
+       is set correctly within the exit trap.
+       (AS_TMPDIR): Use it.
+       * acgeneral.m4 (AC_MSG_ERROR): Likewise,
+
 2000-10-29  Pavel Roskin  <proski@gnu.org>
 
        * acgeneral.m4 (AC_CHECK_TOOL): Set VARIABLE also when using the
index 7987215666edcf9c6e265a6cdb9b712d2568732d..4dbd3c09aa0e8968a33483f62b49040f9b2ecc21 100644 (file)
@@ -2794,7 +2794,7 @@ _AC_ECHO([configure: WARNING: $1], 2); }])
 define([AC_MSG_ERROR],
 [{ _AC_ECHO([configure:__oline__: error: $1], AC_FD_LOG)
   _AC_ECHO([configure: error: $1], 2)
-  exit m4_default([$2], 1); }])
+  AS_EXIT([m4_default([$2], 1)]); }])
 
 
 # AU::AC_CHECKING(FEATURE)
index 7987215666edcf9c6e265a6cdb9b712d2568732d..4dbd3c09aa0e8968a33483f62b49040f9b2ecc21 100644 (file)
@@ -2794,7 +2794,7 @@ _AC_ECHO([configure: WARNING: $1], 2); }])
 define([AC_MSG_ERROR],
 [{ _AC_ECHO([configure:__oline__: error: $1], AC_FD_LOG)
   _AC_ECHO([configure: error: $1], 2)
-  exit m4_default([$2], 1); }])
+  AS_EXIT([m4_default([$2], 1)]); }])
 
 
 # AU::AC_CHECKING(FEATURE)
index 7c3360dfb81e295e5c72d6474cfeb0268c0c0f8a..eb43f2ec195198bc64136be6f03d993796293155 100644 (file)
@@ -98,6 +98,18 @@ define([AS_UNSET],
 [$ac_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
 
 
+# AS_EXIT([EXIT-CODE = 1])
+# ------------------------
+# Exit and set exit code to EXIT-CODE in the way that it's seen
+# within "trap 0".
+#
+# We cannot simply use "exit N" because some shells (zsh and Solaris sh)
+# will not set $? to N while running the code set by "trap 0"
+# So we set $? by executing "exit N" in the subshell and then exit.
+define([AS_EXIT],
+[{ (exit m4_default([$1], 1)); exit; }])
+
+
 
 
 ## ------------------------------------------- ##
@@ -189,7 +201,7 @@ define([AS_TMPDIR],
 $debug ||
 {
   trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
-  trap 'exit $?' 1 2 13 15
+  trap 'AS_EXIT([$?])' 1 2 13 15
 }
 
 # Create a (secure) tmp directory for tmp files.
@@ -204,6 +216,6 @@ $debug ||
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
-   exit 1;
+   AS_EXIT
 }dnl
 ])# AS_TMPDIR
diff --git a/m4sh.m4 b/m4sh.m4
index 7c3360dfb81e295e5c72d6474cfeb0268c0c0f8a..eb43f2ec195198bc64136be6f03d993796293155 100644 (file)
--- a/m4sh.m4
+++ b/m4sh.m4
@@ -98,6 +98,18 @@ define([AS_UNSET],
 [$ac_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
 
 
+# AS_EXIT([EXIT-CODE = 1])
+# ------------------------
+# Exit and set exit code to EXIT-CODE in the way that it's seen
+# within "trap 0".
+#
+# We cannot simply use "exit N" because some shells (zsh and Solaris sh)
+# will not set $? to N while running the code set by "trap 0"
+# So we set $? by executing "exit N" in the subshell and then exit.
+define([AS_EXIT],
+[{ (exit m4_default([$1], 1)); exit; }])
+
+
 
 
 ## ------------------------------------------- ##
@@ -189,7 +201,7 @@ define([AS_TMPDIR],
 $debug ||
 {
   trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
-  trap 'exit $?' 1 2 13 15
+  trap 'AS_EXIT([$?])' 1 2 13 15
 }
 
 # Create a (secure) tmp directory for tmp files.
@@ -204,6 +216,6 @@ $debug ||
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
-   exit 1;
+   AS_EXIT
 }dnl
 ])# AS_TMPDIR