* 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,
This commit is contained in:
Pavel Roskin 2000-10-30 12:29:36 +00:00
parent c27f9181bd
commit acf30e3fb0
5 changed files with 37 additions and 6 deletions

View File

@ -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

View 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)

View 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)

View 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

16
m4sh.m4
View 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