4 ms·
Sounds crazy, but Unix does it and we don't bat an eyelid. [true.c] int main() { return 0; } [false.c] int main() { return 1; }
by jlokier 6y ago
Sounds crazy, but Unix does it and we don't bat an eyelid.
[true.c]
int main() { return 0; }
[false.c]
int main() { return 1; }
- BlueTemplar 6y agoWhy?!
- detaro 6y agoBecause its originally error codes. 0 is "all went well", != 0 is an error code telling you why it failed. I'd guess which then got things added like "programA && programB" as "A went well, so do B and check if B goes well", which kinda gives the logic value true to 0.
- BlueTemplar 6y agoRight, should have remembered that from that time I got into C...
- detaro 6y agoAlthough C does map 0 to false, so it really is a shell-ism, despite the return code pattern being used in C and other places.