I've been Bash scripting for a while and I'm wondering if there's any difference between these two forms of negation with the test
command:
if [ ! condition ]; then
fi
if ! [ condition ]; then
fi
The first tells the shell to pass the arguments ! condition
to test, letting the program take care of the negation itself. On the other hand, the second passes condition
to test and lets the shell itself negate the error code.
Are there any pitfalls I should be aware of when choosing between these two forms? What values of $condition
could make the results differ between them?
(I seem to remember reading an article a while ago discussing this, but I don't remember how to find it/exactly what was discussed.)