bug-bash
[Top][All Lists]
Advanced

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

Re: 'test' builtin of bash returns wrong value for '! -a FILE' operation


From: Chet Ramey
Subject: Re: 'test' builtin of bash returns wrong value for '! -a FILE' operation
Date: Mon, 8 Nov 2010 10:01:47 -0500

> "help test" says:
> 
>       See the bash manual page bash(1) for the handling of
>       parameters (i.e., missing parameters).
> 
> which does not really tempt me to look at the manual.

You should probably ask the person who added that to Debian's version of
bash.

> bash(1) says:
> 
>       Expressions may be combined using the following
>       operators, listed in decreasing order of precedence.

The phrase you're quoting appears in both the description of the [[ conditional
command and the test/[ builtin.  If you're quoting the latter, why omit the
next sentence, which reads:

The evaluation depends on the number of arguments; see below.

>               3 arguments
>                       If the second argument is one of the
>                       binary conditional operators listed above
>                       under CONDITIONAL EXPRESSIONS, the result
>                       of the expression is the result of the
>                       binary test using the first and third
>                       arguments as operands.  The -a and -o
>                       operators are considered binary operators
>                       when there are three arguments.
> 
> That answers the question.  Unfortunately, the next sentence is
> inconsistent with that answer:
> 
>                                                        If the first
>                       argument is !, the value is the negation of
>                       the two-argument test using the second and
>                       third arguments.
> 
> Suggested changes:
> 
>  1. Change the parenthesis in "help bash" to something like
>     "(e.g., operator precedence and missing parameters)".

Again, talk to the Debian maintainer who added it.

>  2. Change the second paragraph in the description in bash(1) of
>     the test builtin to something like
> 
>       Expressions may be combined using the following operators.
>       The evaluation depends on the number of arguments; see below.
>       When 5 or more arguments are present, this list is in
>       decreasing order of precedence.

Something like that is reasonable.

>  3. Add the word "Otherwise," before "If the first argument is !" in
>     the 3-argument case.

The sentences are supposed to indicate precedence.  It would actually
be clearer if they were separated into bullet points, as they are in
the Posix standard.  I'll look at doing that.

Chet

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



reply via email to

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