The example below echoes 1, as expected:
test -f /usr/bin
echo "$?" #1
Why does the following example echo 0?
if [[ -f /usr/bin ]]; then
echo "Inside if statement" # This line is never executed
fi
echo "$?" #0
I know that the $?evaluates to the returned value of the last executed command. In my understanding, the last executed command is test, that is implicitly called by the if statement, since the condition evaluates to false it should return 1, but when I execute it, it returns 0. Can anybody explain why the behavior is different than when test is executed directly (like in the first example)?
According to
man bash: