Bash Rules
Shell scripting commands for automation, text processing, conditionals, loops, and writing maintainable Bash scripts.
5 rules
POSIX Portability Guidelines
Write portable shell scripts by avoiding bashisms when targeting /bin/sh, using POSIX-compliant constructs, and clearly declaring the required shell in the shebang line.
Always Quote Variables and Substitutions
Every variable expansion and command substitution in Bash must be double-quoted to prevent word splitting, glob expansion, and catastrophic bugs with filenames containing spaces.
ShellCheck Compliance Required
All Bash scripts must pass ShellCheck static analysis with zero warnings — catch quoting bugs, deprecated syntax, and portability issues before they reach production.
Always Enable Strict Mode
Every Bash script must begin with strict mode flags — set -euo pipefail — to catch errors early, prevent undefined variable usage, and propagate pipeline failures.
Variable Naming and Declaration Standards
Enforce consistent variable naming in Bash — lowercase snake_case for locals, UPPER_SNAKE_CASE for exports, readonly for constants, and local declarations inside functions.