Shell Script Testing with Bats

We’ve all been there: a small shell script that starts as a quick helper suddenly becomes a critical part of your workflow. Then one day, it breaks - maybe because of a missing argument, a typo, or an unexpected input. Debugging at 2 AM isn’t fun. That’s why adding tests to your shell scripts is a lifesaver. With Bats (Bash Automated Testing System), you can catch these issues early and make your scripts as reliable as any other piece of software. ...

February 13, 2024 · 2 min · 286 words · Micha Kops

Linux Snippets

These are not only linux snippets but also bash snippets and snippets using tools that run under Linux, *nix or sometimes even MacOSX, I should reorder this article someday ;) Settings for more reliable bash scripts set -euo pipefail this gives us …​ -e: exit script if a single command fails -u: exit script if an unset variable is used -o pipefail: return value of a pipeline is the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status ...

March 1, 2010 · 17 min · 3541 words · Micha Kops