From acf30e3fb0cbf5b9fd2affa87c65228d20b3e8ad Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Mon, 30 Oct 2000 12:29:36 +0000 Subject: [PATCH] * 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, --- ChangeLog | 7 +++++++ acgeneral.m4 | 2 +- lib/autoconf/general.m4 | 2 +- lib/m4sugar/m4sh.m4 | 16 ++++++++++++++-- m4sh.m4 | 16 ++++++++++++++-- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6215da98..e4cf5260 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-10-30 Pavel Roskin + + * 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 * acgeneral.m4 (AC_CHECK_TOOL): Set VARIABLE also when using the diff --git a/acgeneral.m4 b/acgeneral.m4 index 79872156..4dbd3c09 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -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) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 79872156..4dbd3c09 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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) diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 7c3360df..eb43f2ec 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/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 diff --git a/m4sh.m4 b/m4sh.m4 index 7c3360df..eb43f2ec 100644 --- 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