Arbitrary execution in bash
According to a recent post I’ve now lost,
https://yossarian.net/til/post/some-surprising-code-execution-sources-in-bash/
you can safely do arithmetic in pure bash (i.e., without
/usr/bin/[).printfcan parse a numeric literal without performing “Arithmetic Expansion” (ACE in a trenchcoat):
printf -v parsedNum "%d" "$untrustedInput"
That printf will return non-zero if it didn’t parse, but it will also set parsedNum to zero, so even if you don’t check for a return code parsedNum is safe to evaluate in Arithmetic Expansion, as far as we can tell
Some caveats1.