I came across a if/then statement like this:
if ! foo ; then
echo "blah"
exit 1
fi
What specifically does if !
mean? "If the result of foo
is not true?" "If the exit code of foo
is not 0"?
shell
I came across a if/then statement like this:
if ! foo ; then
echo "blah"
exit 1
fi
What specifically does if !
mean? "If the result of foo
is not true?" "If the exit code of foo
is not 0"?
Best Answer
!
inverts the meaning of the exit status of the command -- it's part of POSIX shell syntax, it's not part ofif
. From the POSIX spec: