On Bash Testing: Design, Not Just Safety
Testing as a topic is a minefield already when it comes to full-fledged programming languages, let’s not even talk about it for shell scripting.
Or shall we?
You see, whether you write software to test other software, or you just fire up a script from the command line and keep running it over and over again until you nail it, that’s still testing, right?
Have you ever been woken up at night because a script failed six months after you wrote it? Or one year later? Or five years later? — For the love of my life, that thing was supposed to be temporary! There’s nothing more permanent than a temporary solution, they say.
Designing Modular Bash: Functions, Namespaces, and Library Patterns
You’ve written Bash scripts before. Maybe you’ve automated a deployment, wrangled some log files, or stitched together a few commands to save time. But as your scripts grow, something changes. What started as a clean 20-line helper becomes a 200-line sprawl. Functions call functions that modify global variables. You copy-paste code between scripts because extracting shared logic feels harder than it should be. The script works, but it’s fragile, and you’re the only person who can maintain it.