Vincent Lefevre <[EMAIL PROTECTED]> writes:

> On 2008-02-08 16:04:40 +0100, Wolfram Fenske wrote:
>> Oliver Kiddle <[EMAIL PROTECTED]> writes:
>> 
>> > The following is a bug reported for the Debian ksh package. Thanks
>> 
>> [...]
>> 
>> > According to POSIX[*], "test \( ! -e \)" is a 4-argument test and is
>> > here equivalent to "test ! -e".
>> 
>> Where specifically does the POSIX standard say that?
>
> This was in the forwarded message you replied to:
>
>   http://www.opengroup.org/onlinepubs/009695399/utilities/test.html

I did notice that.  See, when I said "specifically" I didn't mean
"Quote me a document with a couple hundred lines of text -- again."
But never mind, I think I found the passage you were referring to:

--8<---------------cut here---------------start------------->8---
The algorithm for determining the precedence of the operators and the
return value that shall be generated is based on the number of
arguments presented to test. [...]

In the following list, $1, $2, $3, and $4 represent the arguments
presented to test:

[...]

* 2 arguments:

    * If $1 is '!', exit true if $2 is null, false if $2 is not null.
    
    * If $1 is a unary primary, exit true if the unary test is true,
      false if the unary test is false.
    
    * Otherwise, produce unspecified results.

[...]

* 4 arguments:

    * If $1 is '!', negate the three-argument test of $2, $3, and $4.
    
    * [XSI] [Option Start] If $1 is '(' and $4 is ')', perform the
      two-argument test of $2 and $3. [Option End]
    
    * Otherwise, the results are unspecified.
--8<---------------cut here---------------end--------------->8---

>> I read
>> 
>>  $ test \( ! -e \)
>> 
>> as an instance of "( expression )".
>
> Yes, where expression is a 2-argument test.
>
>> However, the expresion is malformed because "-e" does not have an
>> argument.
>
> No, it is equivalent to the 2-argument test:
>
>   test ! -e
>
> where -e is just a string. See
>
>   http://www.opengroup.org/onlinepubs/009695399/utilities/test.html
>
>> The Gnu test's solution of treating "test \( ! -e \);" as "test ! 
>> -e;" may be nice, but it requires the parser to be *very*
>> forgiving, which IMO is not always a good thing.
>
> No, the parser just needs to follow the POSIX specification, which
> is quite clear here.

You're right.  I jumped to conclusions by assuming "-e" was used as a
primary, but it's actually used as a plain string, making the test
case equivalent to

  test \( ! foo \)

-- 
Wolfram Fenske

A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to