Why do scripting languages use a reverse convention for indicating TRUE and FALSE?
by hazel from LinuxQuestions.org on (#4QSAZ)
In C, numerals have a boolean significance. Zero is FALSE as are its equivalents: the NULL pointer and the NULL character. Non-zero numbers are TRUE; in practice TRUE=1. This is clearly intuitive. Computers work in binary: 1 and 0, on and off, set and unset, pulse or no pulse. It seems logical that if there is no pulse when a pulse was expected, that signifies FALSE.
But when calling exit() in your program, you pass 0 for success and 1 for error or failure. That's because a script may need to analyse the behaviour of your program and all Unix scripting languages use that convention rather than the more intuitive one. I assume there must be some historical reason for that. Does anyone know how it originated?


But when calling exit() in your program, you pass 0 for success and 1 for error or failure. That's because a script may need to analyse the behaviour of your program and all Unix scripting languages use that convention rather than the more intuitive one. I assume there must be some historical reason for that. Does anyone know how it originated?