I love shell scripts because they’re so pragmatic and often allow me to get jobs done really quickly.
But sadly they’re full of pitfalls. Pitfalls everywhere you look.
Today, a coworker – who’s highly skilled, not a newbie by any means – ran into this:
$ bash -c 'set -u; foo=bar; if [[ "$foo" -eq "bar" ]]; then echo it matches; fi'
bash: line 1: bar: unbound variable
Why’s that happening? I know the answer. Do you? 😂
Stuff like that made me stop using shell scripts at work, unless they’re just 4 or 5 lines of absolutely trivial code. It’s now Python instead, even though the code is often much longer and clunkier, but at least people will understand it more easily and not trip over it when they make a tiny change.