Skip to content

Commit aeb6be7

Browse files
committed
Mention set -u and ${arg:?message}
Closes #29. Closes #37.
1 parent f7cc927 commit aeb6be7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

README.md

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

0 commit comments

Comments
 (0)