shell scripts are a poor choice for evolving software:
- ❌ (unit) test code for
shellscripts is near zero - ❌ no default error detection (forget
set -eand an undetected disaster bubbles through the call stack) - ❌ cryptic "write-only" syntax (e.g.
echo "${file_path##*/}"vsos.path.basename(file_path)) - ❌ subtle, error-prone pitfalls (e.g.
shoptnuances) - ❌ unpredictable local/user overrides (e.g. PATH points to unexpected binaries)
- ❌ less cross-platform than it seems even on *nixes (e.g. divergent command behaviors: macOS vs Linux)
- ❌ no stack traces on failure (which encourages noisy, excessive logging instead)
- ❌ limited native data structures (no nested ones)
- ❌ no modularity (code larger than one-page-one-file is cumbersome)
- ❌ no external libraries/packages (no enforce-able dependencies)
- ❌ when shell scripts multiply, they inter-depend for reuse (by source-ing) into an entangled mess
- ❌ being so unpredictable makes shell scripts high security risks
- ❌ slow
- ...
Do not get me wrong:
- We might be
shellchampions to abuse it beyond its limits to get sh*t done. - But others may want to help too - instead, they drown in
shellhell.
Why not python?
The main reason I used to resort to shell:
- The need for the extra “body movements” to provide required python, populate the
venvand activate it. - Automating this for any environment immediately adds wrappers which are likely
shellscripts anyway.
How to fix all this?
One attempt is:
https://github.com/uvsmtid/protoprimer
an argless reusable one-liner to bootstrap the environment with (almost) zero pre-requisites that runs everywhere:
./prime
- takes off with a wild
pythonversion (whatever is in $PATH) - switches it in-flight to the required
pythonversion - hands over inside a comfy isolated
venvwith all dependencies pinned
Top comments (0)