Martijn Dekker dixit:
>Makes complete sense and I should have figured this out myself. Sorry
>for the noise and thanks for the references.
Oh well, others can still learn from it. (Note that -o for option is
also not POSIX, but POSIX rules still apply, and [[…]] doesn’t have
this problem.)
>I gu
Op 25-09-16 om 22:52 schreef Thorsten Glaser:
> Per XSI, -o is a binary primary:
[...]
> Well, $1 is '!' and therefore true. Same for $3, which is
> 'noclobber' and therefore true. That means that the result
> of -o is also true.
Makes complete sense and I should have figured this out myself. Sorr
Martijn Dekker dixit:
> [ ! -o noclobber ]
>
>amounts to a no-op, always returning exit status 0.
This is the same as:
test ! -o noclobber
POSIX says:
The algorithm for determining the precedence of the operators
and the return value that shall be generated is base
The '!' operator in the legacy test/[ builtin does not invert the result
of the -o operator. Consequently the command
[ ! -o noclobber ]
amounts to a no-op, always returning exit status 0.
Proof:
$ set -o noclobber && [ -o noclobber ] && [ ! -o noclobber ] && echo bug
bug
Interestingly