[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 01-as-exit.patch
From: |
Akim Demaille |
Subject: |
FYI: 01-as-exit.patch |
Date: |
16 Jan 2001 11:18:42 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake) |
Index: ChangeLog
from Akim Demaille <address@hidden>
* m4sh.m4 (AS_EXIT): Don't rely on exit == exit $?.
Reported by Tim Van Holder.
Index: THANKS
--- THANKS Fri, 12 Jan 2001 22:21:56 +0100 akim (ace/0_THANKS 1.28 666)
+++ THANKS Mon, 15 Jan 2001 22:19:25 +0100 akim (ace/0_THANKS 1.28 666)
@@ -134,8 +134,9 @@
Stu Grossman address@hidden
Syd Polk address@hidden
T.E. Dickey address@hidden
-Theodore Ts'o" address@hidden
-Thomas Winder address@hidden
+Theodore Ts'o" address@hidden
+Thomas Winder address@hidden
+Tim Van Holder address@hidden
Tom Lane address@hidden
Tom Purcell address@hidden
Tom Tromey address@hidden
Index: doc/autoconf.texi
--- doc/autoconf.texi Sat, 13 Jan 2001 11:52:14 +0100 akim (ace/16_autoconf.t
1.61.2.97 666)
+++ doc/autoconf.texi Mon, 15 Jan 2001 19:53:44 +0100 akim (ace/16_autoconf.t
1.61.2.97 666)
@@ -5585,7 +5585,21 @@ @node Limitations of Builtins, Limitatio
@item @command{exit}
@c -----------------
@cindex @command{exit}
address@hidden FIXME: A better merging between this item and `trap' is welcome.
+The default value of @command{exit} is supposed to be @code{$?},
+unfortunately some shell, such as the @sc{djgpp} port of Bash 2.04, just
+perform @samp{exit 0}.
+
address@hidden
+bash-2.04$ foo=`exit 1` || echo fail
+fail
+bash-2.04$ foo=`(exit 1)` || echo fail
+fail
+bash-2.04$ foo=`(exit 1); exit` || echo fail
+bash-2.04$
address@hidden example
+
+Using @samp{exit $?} restores the expected behavior.
+
Some shell scripts, such as those generated by @command{autoconf}, use a
trap to clean up before exiting. If the last shell command exited with
nonzero status, the trap also exits with nonzero status so that the
@@ -5813,7 +5827,7 @@ @node Limitations of Builtins, Limitatio
@c -----------------
@cindex @command{trap}
It is safe to trap at least the signals 1, 2, 13 and 15. You can also
-trap 0, i.e., have the trap run when the script end (either via an
+trap 0, i.e., have the trap run when the script ends (either via an
explicit @command{exit}, or the end of the script).
Although @sc{posix} is not absolutely clear on that point, it is widely
@@ -5843,11 +5857,7 @@ @node Limitations of Builtins, Limitatio
set the exit status to 42 for Zsh, and the second to trigger the trap
and pass 42 as exit status for Bash.
-Note that in Bourne shell an unqualified @command{exit} is equivalent to
address@hidden $?}, hence you may actually abbreviate it as @samp{(exit 42);
-exit}.
-
-The shell in FreeBSD 4.0 has the following bug: @samp{ $?} is reset to 0
+The shell in FreeBSD 4.0 has the following bug: @samp{$?} is reset to 0
by empty lines if the code in inside trap.
@example
Index: m4sh.m4
--- m4sh.m4 Sat, 13 Jan 2001 11:47:33 +0100 akim (ace/b/41_m4sh.m4 1.18 666)
+++ m4sh.m4 Mon, 15 Jan 2001 19:41:46 +0100 akim (ace/b/41_m4sh.m4 1.18 666)
@@ -104,8 +104,10 @@
# 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.
+# Other shells don't use `$?' as default for `exit', hence just repeating
+# the exit value can only help improving portability.
m4_define([AS_EXIT],
-[{ (exit m4_default([$1], 1)); exit; }])
+[{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
# AS_IF(TEST, [IF-TRUE], [IF-FALSE])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: 01-as-exit.patch,
Akim Demaille <=