Skip to content

Mention 'set -u' and ${arg:?message} #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ Keep in mind this is not for general shell scripting, these are rules specifical
* Always use `local` when setting variables, unless there is reason to use `declare`
* Exception being rare cases when you are intentionally setting a variable in an outer scope.
* Variable names should be lowercase unless exported to environment.
* Always use `set -eo pipefail`. Fail fast and be aware of exit codes.
* Use `|| true` on programs that you intentionally let exit non-zero.
* Fail fast and be aware of exit codes
* Always use `set -uo pipefail` (fail on unset variables, and fail if any command in a pipeline fails)
* Consider also using `set -e` (terminate script on _any_ non-zero exit), with an ERR trap
* Use `|| true` on programs that you intentionally let exit non-zero.
* Use something like `: ${arg:?Expected argument 'arg'}` when you don't have time to do proper argument parsing
* Never use deprecated style. Most notably:
* Define functions as `myfunc() { ... }`, not `function myfunc { ... }`
* Always use `[[` instead of `[` or `test`
Expand Down