[sf-lug] bash strict mode (set -e)? - not so fast unless you know these quirks
Ron
ron at bclug.ca
Thu Aug 14 23:32:36 PDT 2025
Looks like this is off-list. I'll add the list...
Ken Shaffer wrote on 2025-08-14 13:15:
> Well, from the bash man page:
> ((expression))
> The expression is evaluated according to the rules
> described below under ARITHMETIC EVALUATION. If the value of the
> expression is non-zero, the return status is 0; otherwise the return
> status is 1.
>
> It does what it says in this case.
True, but it's weird, counter-intuitive behaviour, and could cause an
app to exit without any actual error, making debugging a nightmare.
A dev might not know that the sum being generated is zero if user input
is involved.
Probably still more valuable than not using it (at least during dev),
but it's good to be aware of the subtle implications!
More information about the sf-lug
mailing list