4.3.9 Return value of the command
Each command returns its exit status as the return value.
This return value can be accessed by the $? shell variable
immediately after the execution.
$ [ 1 = 1 ] ; echo $?
$ [ 1 = 2 ] ; echo $?
Please note that, when the return value is used in the logical context for the
shell, success is treated as the logical
TRUE. This is somewhat non-intuitive since
success bears value zero.
Shell conditionals, Section