[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: -a is not -e ?! wrong entry in "man bash" ?
From: |
Chet Ramey |
Subject: |
Re: -a is not -e ?! wrong entry in "man bash" ? |
Date: |
Tue, 04 Mar 2003 11:32:59 -0500 |
> Machine Type: i686-pc-linux-gnu
>
> Bash Version: 2.05b
> Patch Level: 0
> Release Status: release
>
> Description:
>
> We have found a very strange entry in the man-page:
> line 1748:
> ~ -a file
> ~ True if file exists.
I should never have made this a unary primary, ksh compatibility aside.
> line 1756:
> ~ -e file
> ~ True if file exists.
>
> - -a and -e should do the same according to the man-page, but they dont!
Yes, they do. Really.
> if [ -a /bin/bash ] is TRUE if /bin/bash exists.
> if [ ! -a /bin/bash ] should be FALSE if /bin/bash exists, BUT it
> returns TRUE.
>
> if [ -e /bin/bash ] is TRUE if /bin/bash exists.
> if [ ! -e /bin/bash ] is FLASE if /bin/bash exists.
>
> So -a is not -e as the man-page says. So what does -a really do ? Is
> this a bash bug or a man-page "bug" ?
Neither. This question is answered, for the most part, by item E1 in
the Bash FAQ. The short answer is:
test/[ works off the number of arguments
binary primaries have higher precedence than ! for the three-argument case
-a and -o are considered binary primaries for the three-argument case
A more complete answer is in the FAQ.
> Fix:
> ~ Never use -a :)
If you mean as a unary primary, I would not disagree.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Chet Ramey, ITS, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/