3 ms·
Y'all writing bash scripts without set -u and error checking? One of the first technical docs I read online after discovering Linux was a best practices guide
by corobo 5y ago
Y'all writing bash scripts without set -u and error checking?
One of the first technical docs I read online after discovering Linux was a best practices guide for bash scripts (or some similar version of these if my memory is lapsing)
http://mywiki.wooledge.org/BashGuide/Practices http://mywiki.wooledge.org/BashGuide/Practices
http://mywiki.wooledge.org/BashPitfalls http://mywiki.wooledge.org/BashPitfalls
- hedora 5y agoTry: set -euxo pipefail Enjoy!
- I_complete_me 5y agoWhat does the pipefail part do?
- vulcan01 5y agoSay you have `command1 | command2` in your script, and command1 fails. Bash will just skip over the failure and continue. `set -o pipefail` tells Bash to exit the program on such a failure.
- digisign 5y agoDefaults matter. This came up in a search: https://www.jason.af/defaults-matter/ https://www.jason.af/defaults-matter/ "Even the most well-intentioned people have a finite amount of energy to fight against a system that pushes toward bad outcomes."
- rascul 5y ago> Y'all writing bash scripts without set -u Yes. I can account for unset variables. > and error checking? No. Everything which can error is checked and handled.
- anamax 5y ago> Y'all writing bash scripts without set -u and error checking? Just last week someone pointed to all of the cases where -u doesn't do what one would expect.
- rascul 5y agohttps://mywiki.wooledge.org/BashFAQ/112 https://mywiki.wooledge.org/BashFAQ/112