Or "[ ! -a file ] is always true because -a becomes logical AND. Use -e instead."
[ ! -a file ]
-a
-e
if [ ! -o braceexpand ] then .. fi
if [[ ! -o braceexpand ]] then .. fi
or
if ! [ -o braceexpand ] then .. fi
Bash interprets [ ! -o opt ] as [ "!" ] || [ "opt" ] instead of negating the condition. As a result, the condition is always true.
[ ! -o opt ]
[ "!" ] || [ "opt" ]
Avoid this by using [[ ! -o opt ]] or ! [ -o opt ].
[[ ! -o opt ]]
! [ -o opt ]
The same issue applies to [ ! -a file ], but this is easier fixed using POSIX standard [ ! -e file ].
[ ! -e file ]
None.
There was an error while loading. Please reload this page.