3 ms·
I agree. Shell scripts are awesome until you reach a certain threshold of complexity, and that threshold is... low. Error handling is particularly problematic.
by lobster_johnson 10y ago
I agree. Shell scripts are awesome until you reach a certain threshold of complexity, and that threshold is... low.
Error handling is particularly problematic. If you know all the tricks (things like set -e, set -o pipefail, always capture stderr, etc.), it's not too bad, but there are still so many traps that the mental overhead of catching every single edge case is exhausting.
One nasty issue with Bash is quoting, escaping and word splitting, because almost everything in Bash is about string manipulation. There are so many edge cases: $FOO is not the same as "$FOO", and sometimes you have no choice but to turn it into an array with eval FOO=($FOO) if you need mimic Bash's tokenization behaviour (e.g. respect backslashes and quoting).
(Yes, Bash has arrays! A lot of scripts get simpler when you realize this.)
These days I reach for Ruby very quickly even for small things.