]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Clarify portability pitfall of test.
authorEric Blake <ebb9@byu.net>
Fri, 11 Sep 2009 02:05:21 +0000 (20:05 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 11 Sep 2009 02:18:39 +0000 (20:18 -0600)
* doc/autoconf.texi (Limitations of Builtins) <test>: Give more
reasons why -a and -o are not portable.
Reported by Reuben Thomas.

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

index 80f560994715170d56142239ca589e4df19ee7b8..6e585f732d855a39d183100f8c7ef32a35b80962 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-10  Eric Blake  <ebb9@byu.net>
+
+       Clarify portability pitfall of test.
+       * doc/autoconf.texi (Limitations of Builtins) <test>: Give more
+       reasons why -a and -o are not portable.
+       Reported by Reuben Thomas.
+
 2009-09-10  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Document sed limitation with escaped metacharacters.
index 82a9f2aa3d1963e2b12ea5bf2c8bd25b75f1b88e..a43c6142f14e664dcb37cd2312d5d0534f6d6a91 100644 (file)
@@ -16388,12 +16388,18 @@ that name in Autoconf code is asking for trouble since it is an M4 quote
 character.
 
 The @option{-a}, @option{-o}, @samp{(}, and @samp{)} operands are not
-portable and should be avoided.  Thus, portable uses of @command{test}
-should never have more than four arguments, and scripts should use shell
-constructs like @samp{&&} and @samp{||} instead.  If you combine
-@samp{&&} and @samp{||} in the same statement, keep in mind that they
-have equal precedence, so it is often better to parenthesize even when
-this is redundant.  For example:
+present in all implementations, and have been marked obsolete by Posix
+2008.  This is because there are inherent ambiguities in using them.
+For example, @samp{test "$1" -a "$2"} looks like a binary operator to
+check whether two strings are both non-empty, but if @samp{$1} is the
+literal @samp{!}, then some implementations of @command{test} treat it
+as a negation of the unary operator @option{-a}.
+
+Thus, portable uses of @command{test} should never have more than four
+arguments, and scripts should use shell constructs like @samp{&&} and
+@samp{||} instead.  If you combine @samp{&&} and @samp{||} in the same
+statement, keep in mind that they have equal precedence, so it is often
+better to parenthesize even when this is redundant.  For example:
 
 @smallexample
 # Not portable: