cromwell@dp.2y.net wrote:
> if ! [ -a /bin/bash ]; echo "bash not found"; fi
> if [ ! -a /bin/bash ]; echo "bash not found"; fi
> Both should produce no output, because of course I have bash,
> but the 2nd line prints "bash not found"
It looks like the "-a" argument is interpreted as the binary "and"
operator, and the "!" and "/bin/bash" are tested for being nonempty
strings, so the result is true. It's generally best to keep [ ]
expressions as simple as possible and move negations, ands, and ors
outside them, using "!", "&&", and "||". The parsing of [ ]
expressions is not always well-defined, and even when it is, it won't
necessarily be what you expect.
paul