From: Ralf Wildenhues Date: Sun, 6 Jun 2010 09:59:25 +0000 (+0200) Subject: Clarify OpenBSD sh errexit issue with compound commands. X-Git-Tag: v2.66~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=521a4615578b5a9908fd6af9a8085ba7009cb38a;p=thirdparty%2Fautoconf.git Clarify OpenBSD sh errexit issue with compound commands. * doc/autoconf.texi (Limitations of Builtins): Only the last command in a compound list is problematic. Tested on OpenBSD 4.4. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 9c626346..f71d53a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-06-08 Ralf Wildenhues + + Clarify OpenBSD sh errexit issue with compound commands. + * doc/autoconf.texi (Limitations of Builtins): Only the last + command in a compound list is problematic. + Tested on OpenBSD 4.4. + 2010-06-07 Eric Blake Properly quote AC_PREREQ during autoupdate. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index eab9ab21..6a7666b5 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -16877,9 +16877,9 @@ makefiles, and led to circumlocutions like @samp{sh -c 'test -f file || touch file'}, where the seemingly-unnecessary @samp{sh -c '@dots{}'} wrapper works around the bug (@pxref{Failure in Make Rules}). -Even relatively-recent versions of the BSD shell (e.g., -OpenBSD 3.4) wrongly exit with @option{-e} if a command within -@samp{&&} fails inside a compound statement. For example: +Even relatively-recent versions of the BSD shell (e.g., OpenBSD 3.4) +wrongly exit with @option{-e} if the last command within a compound +statement fails and is guarded by an @samp{&&} only. For example: @example #! /bin/sh @@ -16889,14 +16889,17 @@ test -n "$foo" && exit 1 echo one if :; then test -n "$foo" && exit 1 + echo two + test -n "$foo" && exit 1 fi -echo two +echo three @end example @noindent -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 BSD users not to use @samp{sh -e}. +does not print @samp{three}. One workaround is to change the last +instance of @samp{test -n "$foo" && exit 1} to be @samp{if test -n +"$foo"; then exit 1; fi} instead. Another possibility is to warn BSD +users not to use @samp{sh -e}. When @samp{set -e} is in effect, a failed command substitution in Solaris @command{/bin/sh} cannot be ignored, even with @samp{||}.