3 ms·
I've spent a lot of time writing portable shell scripts which needed to run on Arch Linux (GNU coreutils), Alpine Linux (busybox), and MacOS (whatever their def
by nvllsvm 4y ago
I've spent a lot of time writing portable shell scripts which needed to run on Arch Linux (GNU coreutils), Alpine Linux (busybox), and MacOS (whatever their defaults are). Even used shellcheck to lint and ran all scripts with dash shell to validate POSIX-compliance.
Now? I just pick a minimum version of Python and limit myself to the standard library (Python package management still sucks) and occasional subprocesses (ex. preferring to invoke the zstd cli vs installing the Python package). This tends to be more verbose than shell scripting, but also much clearer - especially when compared to using single-letter flag arguments for options I seldom use.
I also don't generally trust those I share my scripts with to have a deep enough understanding of shell scripting to ensure portability and safety (argument parsing, quoting, and iterating over paths).
- SOLAR_FIELDS 4y agoI also find myself reaching for Python if it’s more than a terse, readable 1-2 line script. A colleague of mine said it pretty well - if your script is doing even minutely complex with jq, it’s probably time to reach for Python.