]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* m4sh.m4 (AS_EXIT): Don't rely on exit == exit $?.
authorAkim Demaille <akim@epita.fr>
Tue, 16 Jan 2001 10:27:19 +0000 (10:27 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 16 Jan 2001 10:27:19 +0000 (10:27 +0000)
Reported by Tim Van Holder.

ChangeLog
THANKS
doc/autoconf.texi
lib/m4sugar/m4sh.m4
m4sh.m4

index 35abbb8a60c06074b37d0559ffdc37f2f5409d7f..292615fc9890347900b0017189534ac518456549 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-01-16  Akim Demaille  <akim@epita.fr>
+
+       * m4sh.m4 (AS_EXIT): Don't rely on exit == exit $?.
+       Reported by Tim Van Holder.
+
 2001-01-16  Akim Demaille  <akim@epita.fr>
 
        * Makefile.am (editpl, editsh): Merge into...
diff --git a/THANKS b/THANKS
index 16d1aea95cdd830903d88b87a8c8de7484044e10..21ed02c442fa6bcad166c141c1f77c9f2daecac4 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -134,8 +134,9 @@ Steve Robbins               steve@nyongwa.montreal.qc.ca
 Stu Grossman           grossman@cygnus.com
 Syd Polk               spolk@cygnus.com
 T.E. Dickey            dickey@clark.net
-Theodore Ts'o"         tytso@MIT.EDU
-Thomas Winder          tom@vlsivie.tuwien.ac.AT
+Theodore Ts'o"         tytso@mit.edu
+Thomas Winder          tom@vlsivie.tuwien.ac.at
+Tim Van Holder         tim.van.holder@pandora.be
 Tom Lane               tgl@sss.pgh.pa.us
 Tom Purcell            Tom.Purcell@wang.com
 Tom Tromey             tromey@cygnus.com
index e89f534f3cfa4b8c73aea8bebbc1f2b7020bad0f..b2a31d993dd549ef26f7cf70a4934cbcab68b4a2 100644 (file)
@@ -5588,7 +5588,21 @@ as the string composed of a backslash and an n.
 @item @command{exit}
 @c -----------------
 @cindex @command{exit}
-@c 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}.
+
+@example
+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$
+@end 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
@@ -5816,7 +5830,7 @@ expr "x$ac_feature" : '.*[^-a-zA-Z0-9_]' >/dev/null &&
 @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
@@ -5846,11 +5860,7 @@ run @samp{(exit 42); exit 42}, the first @command{exit} being used to
 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
-@samp{exit $?}, 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 32b812047332737bdfc5a54e3a2869a23a2dd449..1e7a2d411e687f9ab815bdd8ecdee5686d1c0399 100644 (file)
@@ -104,8 +104,10 @@ AS_UNSET([CDPATH], [:])
 # 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])
diff --git a/m4sh.m4 b/m4sh.m4
index 32b812047332737bdfc5a54e3a2869a23a2dd449..1e7a2d411e687f9ab815bdd8ecdee5686d1c0399 100644 (file)
--- a/m4sh.m4
+++ b/m4sh.m4
@@ -104,8 +104,10 @@ AS_UNSET([CDPATH], [:])
 # 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])