4 ms·
See also: Why doesn't set -e (or set -o errexit, or trap ERR) do what I expected? https://mywiki.wooledge.org/BashFAQ/105 https://mywiki.wooledge.org/BashFAQ/
by asicsp 3y ago
See also:
Why doesn't set -e (or set -o errexit, or trap ERR) do what I expected?
https://mywiki.wooledge.org/BashFAQ/105 https://mywiki.wooledge.org/BashFAQ/105
What are the advantages and disadvantages of using set -u (or set -o nounset)?
https://mywiki.wooledge.org/BashFAQ/112 https://mywiki.wooledge.org/BashFAQ/112
Safe ways to do things in bash https://github.com/anordal/shellharden/blob/master/how_to_do_things_safely_in_bash.md https://github.com/anordal/shellharden/blob/master/how_to_do...
Better Bash Scripting in 15 Minutes https://robertmuth.blogspot.com/2012/08/better-bash-scripting-in-15-minutes.html https://robertmuth.blogspot.com/2012/08/better-bash-scriptin...
Writing Robust Bash Shell Scripts https://www.davidpashley.com/articles/writing-robust-shell-scripts/ https://www.davidpashley.com/articles/writing-robust-shell-s...
- ndsipa_pomu 3y agoYou missed the most important tip - use ShellCheck on every script you write: https://www.shellcheck.net/ https://www.shellcheck.net/ Personally, I'm a big fan of BASH3 boilerplate: https://github.com/kvz/bash3boilerplate https://github.com/kvz/bash3boilerplate It's fine for BASH versions above v3 and provides decent logging though I typically extend the script so that I can pipe long running commands into its logging framework. It also ensures that you specify the "help" options correctly as it parses the usage information to process the command line arguments with support for short and long options.
- asicsp 3y agoOh yeah, shellcheck is a must have tool.
- ndsipa_pomu 3y agoI think of it as a gateway to writing better scripts. When you first run it and it highlights what it considers to be a problem, you end up reading why it considers it to be a problem and that clues you in on some of the many footguns that Bash has.