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 $?
0
$ [ 1 = 2 ] ; echo $?
1
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.
See
Shell conditionals, Section
13.2.5.