]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Document Tru64 bug with 'set -e'.
authorEric Blake <ebb9@byu.net>
Tue, 18 Nov 2008 15:45:04 +0000 (08:45 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 18 Nov 2008 16:00:51 +0000 (09:00 -0700)
* doc/autoconf.texi (Limitations of Builtins) <trap>: Mention a
bug in mixing 'set -e' with 'trap .. 0'.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi

index 93c085c77676c0663da303e188a17e043a20fffe..543ce5d96fba4a8aff19c44a66bd7207b57978c3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-11-18  Eric Blake  <ebb9@byu.net>
 
+       Document Tru64 bug with 'set -e'.
+       * doc/autoconf.texi (Limitations of Builtins) <trap>: Mention a
+       bug in mixing 'set -e' with 'trap .. 0'.
+       Reported by Ralf Wildenhues.
+
        Document a Solaris /bin/sh bug with 'set -e'.
        * doc/autoconf.texi (Shell Functions): Mention the bug.
 
index 90e6ceee266257dcd8eee3e1a777d64b3ba04050..37becc5f1bbcc93b7d40f888fb3c2ad09fe39a97 100644 (file)
@@ -15425,6 +15425,22 @@ does not print @samp{two}.  One workaround is to use @samp{if test -n
 "$foo"; then exit 1; fi} rather than @samp{test -n "$foo" && exit 1}.
 Another possibility is to warn @acronym{BSD} users not to use @samp{sh -e}.
 
+Portable scripts should not use @samp{set -e} if @command{trap} is used
+to install an exit handler.  This is because Tru64/OSF 5.1 @command{sh}
+enters the trap handler with the exit status of the command prior to the
+one that triggered the errexit handler:
+
+@example
+$ @kbd{bash -c 'trap '\''echo $?'\'' 0; set -e; false'}
+1
+$ @kbd{sh -c 'trap '\''echo $?'\'' 0; set -e; false'}
+0
+@end example
+
+@noindent
+Thus, when writing a script in M4sh, rather than trying to rely on
+@samp{set -e}, it is better to append @samp{|| AS_EXIT([$?])} to any
+statement where it is desirable to abort on failure.
 
 @item @command{shift}
 @c ------------------