The question you are asking when querying a process exit code is "did this program exit with an error?". The default assumption is "no, it completed successfully", so 0 (false) is the logical expected default return.
A function is expected to produce a result - so the question is "what was the result?". !0 (something) is the logical expected default return.
Yes. But it's still contradictory
The question you are asking when querying a process exit code is "did this program exit with an error?". The default assumption is "no, it completed successfully", so 0 (false) is the logical expected default return.
A function is expected to produce a result - so the question is "what was the result?". !0 (something) is the logical expected default return.
I've never found it to be contradictory.
But in shell, 0 is true, not false. The program called true returns 0.
1 reply →