[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Clarify OpenBSD sh errexit issue with compound commands.
From: |
Ralf Wildenhues |
Subject: |
Clarify OpenBSD sh errexit issue with compound commands. |
Date: |
Sun, 6 Jun 2010 12:04:31 +0200 |
User-agent: |
Mutt/1.5.20 (2009-10-28) |
I kept stumbling over the apparent non-failure of false && ... inside
compound lists with OpenBSD sh. So here is a more detailed description
of the bug.
OK?
Thanks,
Ralf
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.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index eab9ab2..6a7666b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -16877,9 +16877,9 @@ Limitations of Builtins
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
address@hidden&&} 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 @@ Limitations of Builtins
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{||}.
- Clarify OpenBSD sh errexit issue with compound commands.,
Ralf Wildenhues <=