Google Shell Style Guide
Google's published rules for writing bash scripts, covering quoting, naming, functions and when to switch to another language.
In more detail
Much of the course's style advice matches it: quote expansions, use [[ ]] and $( ), declare locals, and put main at the bottom. It suggests rewriting a script in a fuller language once it passes about a hundred lines.
Related terms
- ShellCheck — A linter for shell scripts that reports quoting mistakes, portability problems and common bugs, each with a numbered code.
- main function — By convention, a function called main that holds a program's top-level steps and is called once at the end of the file.
- local variable — A variable that exists only inside one function call and cannot be seen or changed from outside it.
Taught in
- Style That Prevents Bugs — Bash Scripting & Command Line Automation