On 10/21/18 5:32 AM, Martin Schulte wrote: > Hello, > > "help test" states that "-a file" and "-e file" do them same ("True if > file exists.") > > This is not true when negating the result as you can see from the output > below. The bash builtin even behaves different than the test from > coreutils.
This is documented behavior consistent with the POSIX standard. It's been this way for so long, there is even a question in the long-dormant FAQ about it (E1). The `test' command's behavior is determined by the number of arguments, as specified by POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128 The help text for test says "The behavior of test depends on the number of arguments. Read the bash manual page for the complete specification." The man page says: 3 arguments The following conditions are applied in the order listed. 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. This is the order in which the POSIX algorithm specifies the conditions. > It looks as if "! -a file" results in "( ! ) -a ( file )" in bash while > it results in "! ( -a file )" in coreutils' test. Coreutils does the tests in a different order than they appear in the POSIX standard. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/