[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "The `-a', `-o', `(', and `)' operands are not portable": please cla
From: |
Eric Blake |
Subject: |
Re: "The `-a', `-o', `(', and `)' operands are not portable": please clarify |
Date: |
Thu, 10 Sep 2009 20:10:59 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Reuben Thomas on 8/4/2009 3:53 PM:
[revisiting an old thread]
> 2009/8/4 Eric Blake <address@hidden>:
>>> What I'd like therefore is a rationale: if -a, -o and parentheses are
>>> not in POSIX 1990, please say so
>> [beautiful rationale from Eric]
>
> Thanks Eric. Could a brief summary of this go in the manual? Something like:
>
> "widely unimplemented and deprecated in POSIX 2008"
Yes, I'm committing this:
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkqpsbMACgkQ84KuGfSFAYAMTwCg0sfchovG8UauIeDsWR1GEtjp
slAAoJF+PmIfLFpj9cwUXf9vbmA9GOkY
=rn56
-----END PGP SIGNATURE-----
>From 841c01f9953cb97b0bfa9d7da042d43ede3b1099 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 10 Sep 2009 20:05:21 -0600
Subject: [PATCH] Clarify portability pitfall of test.
* doc/autoconf.texi (Limitations of Builtins) <test>: Give more
reasons why -a and -o are not portable.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 6 ++++++
doc/autoconf.texi | 18 ++++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d074681..ff99666 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-10 Eric Blake <address@hidden>
+
+ Clarify portability pitfall of test.
+ * doc/autoconf.texi (Limitations of Builtins) <test>: Give more
+ reasons why -a and -o are not portable.
+
2009-09-04 Reuben Thomas <address@hidden> (tiny change)
Mention the Autoconf archive.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 6f06577..36eba53 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -16380,12 +16380,18 @@ Limitations of Builtins
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
address@hidden&&} 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
address@hidden||} 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:
--
1.6.3.3.334.g916e1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: "The `-a', `-o', `(', and `)' operands are not portable": please clarify,
Eric Blake <=