[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AS_EXIT
From: |
Pavel Roskin |
Subject: |
AS_EXIT |
Date: |
Sat, 28 Oct 2000 13:50:57 -0400 (EDT) |
Hello!
This may be a nicer way of dealing with the "exit and trap problem".
ChangeLog:
* m4sh.m4 (AS_EXIT): New macro that exits in the way that
$? is set correctly within the exit trap.
(AS_TMPDIR): Use it.
* acgeneral.m4 (AC_MSG_ERROR): Likewise,
I intentionally didn't try to replace every "exit" - it's hard to test all
those conditions, and I don't want to break things due to subtle newlines,
semicolons etc. Moost of this dirty work can be done later.
But I used AS_EXIT in two places where I could test it.
Now when "zsh config.status" is interrupted by Ctrl-C it exits with the
code 130, not 0.
As a side effect, AC_MSG_ERROR should now be fixed, too :-)
Regards,
Pavel Roskin
_________________________
Index: acgeneral.m4
--- acgeneral.m4 Wed Oct 25 23:40:35 2000
+++ acgeneral.m4 Sat Oct 28 13:38:27 2000
@@ -2795,7 +2795,7 @@
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: m4sh.m4
--- m4sh.m4 Thu Oct 26 05:52:34 2000
+++ m4sh.m4 Sat Oct 28 13:14:19 2000
@@ -98,6 +98,18 @@
[$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 @@
$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 @@
} ||
{
echo "$me: cannot create a temporary directory in $TMPDIR" >&2
- exit 1;
+ AS_EXIT
}dnl
])# AS_TMPDIR
_________________________