A C convention in which 0 is false and something else is true is just a convention. Bash (and unix shells in general), use the opposite convention: 0 is true, something else is false.
$ if ( exit 0 ); then echo true; else echo false; fi true $ if ( exit 1 ); then echo true; else echo false; fi false $ if ( exit 2 ); then echo true; else echo false; fi false
Because of this, true always exits with status 0, and false exits with status 1.
$ true; echo $? 0 $ false; echo $? 1
This can be quite embarrassing for those who are used to the C convention, but in terms of the shell there is a lot more sense: true = success = zero exit status, and false = fail = noxero exit status.
source share