Re:Jo – a shell command to create JSON (2016)
by bb88 on Sunday February 06, 2022 @05:49AM
(#30231290)
It's behavior is really well defined and will stop on a syntax error, type error, or some other error that wasn't handled.
Bash on error will just move on to the next line as if nothing ever happened unless you:
set -eu
set -o pipefail
If you do take the time to deal with pip (which, yes, is a problem) you get access to even more batteries that would have been a pain or just flat out impossible with shell.
(& on many distros, you can use your system package manager. I'm not seeing a material difference between a shell script that requires "apt-get install jo" and a Python script that requires "apt-get install python3-requests" or something.)
But either way, for circumstances where shell is the wrong tool for the job, "invoke python in the middle of this shell script because it's a better tool for this particular part of the job" is a strategy I've used before & will keep using, b/c it produces code that isn't riddled with bugs.