In C and anything written in C, it's always tested against 0, eg. if (0) --> false if (non-0) --> true Return/exit code is different. Easy way to remember is 0 --> success, because there is only one success condition non-0 --> error, because there are many error conditions On 2025-08-19 17:58, Alvin Starr via Talk wrote:
On 2025-08-19 16:16, Ron via Talk wrote:
William Park via Talk wrote on 2025-08-17 21:51:
It's arithematic expression, so an easy way to remember: number 0 --> returns 1 ("fail") number non-0 --> returns 0 ("success") You're right, once one knows about it it's easy to remember.
But it's highly counter-intuitive (*who* here knew about this behaviour before this thread?).
And bash is littered with such weirdness.
This is actually not a bash-ism.
Early Unix (at least V7) used 0 as a successful program completion code. Because numbers other than 0 were used to designate the kind of error.
The most logical would be to make true=1=sucess and false=0=failure but there is no way in the 8bit return code of V7 to specify what the failure was.
This specific problem is older than Bash. Bash just inherited a weird answer.
BSD carried it on with and then Linux. Take a look at /usr/include/sysexits.h
-- Alvin Starr || land: (647)478-6285 Netvel Inc. || home: (905)513-7688 alvin@netvel.net ||
------------------------------------ Description: GTALUG Talk Unsubscribe via Talk-unsubscribe@lists.gtalug.org Start a new thread: talk@lists.gtalug.org This message archived at https://lists.gtalug.org/archives/list/talk@lists.gtalug.org/message/P4KOV5K...