Re:Filenames and Pathnames in Shell: How to Do It Correctly
by js2 on Tuesday June 20, 2023 @02:09PM
(#36408099)
The change was made with bash-4.1:
This is a terse description of the new features added
to bash-4.1 since the release of bash-4.0. [...]
j. The [[ and (( commands are now subject to the setting
of `set -e' and the ERR trap."
Test program:
Running with 3.2.57: Running with 5.1.16: So the arithmetic operation returns non-zero in both cases where it evaluates to 0, but only under bash >= 4.1 does it cause bash to terminate.The moral of the story is to be careful with arithmetic operations that might evaluate to zero, or use this:
(( operation )) || true