19 Aug
2025
19 Aug
'25
4:16 p.m.
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. Two values summing to zero gives the same result as "a" + "b"?!? $ (("b"+"a")) ; echo $? 1 $ ( ((0+0)); echo $? ) 1 $ ( ((0+1)); echo $? ) 0 It's just mindbogglingly illogical and utterly nonsensical (in my not so humble opinion).