By convention, mostly because of the *n?x program test, and the && and || shell operators, a shell script is supposed to regard a program as having "succeeded" if and only if it sets an exit status code of . Thus, any program that sets a nonzero exit status code is regarded to have 'failed'. Occasionally it becomes necessary to set the status code to something other than 0 without doing anything else. To this end, the operating system has a program, called false. There is an analogous program, true, that sets an exit status code of 0. To save time, true and false are sometimes built into the shell itself.

Here is the C source code for false:

int main ()
{
 return 1; /* alternatively, call exit (1) */
};



false is also a keyword of Pascal, providing a Pascal analogue to the Boolean concept of falsehood. A boolean-type expression has a value of false if the corresponding predicate is also false.

C programmers, of course, have no time for a boolean type; but after it was proven1 that it was impossible to design a C++ class with all of the semantic nuances required of a boolean type, the C++ standardization committee added a boolean type (bool) with false as a keyword.


1Scott Meyers provided a very good demonstration of this in C/C++ Users Journal a few years before the ISO C++ Standard was released.