Automating on Unix systems.
WHAT IT IS
The command interpreter on most Unix-like systems, and a scripting language.
WHAT IT SUITS
Automating command sequences File manipulation Deployment and maintenance tasks Gluing programs together
WHAT IT DOES NOT SUIT
Anything with complex logic Anything with substantial data structures Anything requiring maintainability over years
WHAT TO DO WHEN A SCRIPT GROWS
Rewrite it in a proper language.
WHAT THE THRESHOLD IS
Roughly, when it needs functions, arrays and error handling throughout.
WHAT MAKES SHELL SCRIPTS FRAGILE
Unquoted variables, which split on spaces Errors not stopping execution Assumptions about the working directory Assumptions about which commands exist
WHAT TO SET AT THE TOP OF EVERY SCRIPT
Exit on error Exit on undefined variable Failure propagated through pipelines
WHY
Without those, a script continues after a failure and causes damage.
WHAT TO QUOTE
Every variable expansion, always.
WHAT TO USE
A shell script linter, which catches the majority of common faults.
WHAT TO TEST
On a system that matters least, first.