bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] false positive: [ ! -o optname ]


From: Chet Ramey
Subject: Re: [BUG] false positive: [ ! -o optname ]
Date: Sun, 25 Sep 2016 18:05:50 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 9/25/16 5:57 PM, Martijn Dekker wrote:
> Op 25-09-16 om 22:40 schreef isabella parakiss:
>> On 9/25/16, Martijn Dekker <martijn@inlv.org> wrote:
>>> The '!' operator in the legacy test/[ builtin does not invert the result
>>> of the -o operator. Consequently the command
>>>
>>>     [ ! -o noclobber ]
>>>
>>> amounts to a no-op, always returning exit status 0.
> [...]
>> [ ! -o noclobber ] means
>> is '!' a non empty string?  if not, is 'noclobber' a non empty string?
> 
> Wow. Yeah, I suppose that's one possible interpretation. I was going for
> the POSIX one:
> 
> | These primaries can be combined with the following operators:
> |
> | !  expression
> |     True if expression is false. False if expression is true.
> Ref:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128

You need to look at the part of the Posix description where the behavior is
described as being based on the number of arguments.  In particular:

3 arguments:

        If $2 is a binary primary, perform the binary test of $1 and $3.

-a and -o are considered binary primaries for the purposes of a three-
argument test.  This is spelled out pretty clearly in the bash
documentation.

Chet


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]