If I run help if
in bash
then it tells me that the exit status is “the status of the last command executed”. Let’s try it:
if false; then
echo we never get here
fi
echo $?
The last command executed above is clearly false
and yet the if returns true. What gives?