3 ms·
When Failures Align
- Epskampie 6y agoYes, ‘set -euo pipefail’ is a must for safety in every bash script, I had to learn that the hard way too. More info: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_p...
- carlmr 6y agoI'd add the mentioned user suggestion `set -Eeuo pipefail`.
- ochronus 6y agonice post-mortem, it's good that you're practicing it!
- l0b0 6y agoMy current Bash go-to header now includes set -o errexit -o noclobber -o nounset -o pipefail - Exit the script at the first non-zero exit code. - Do not allow clobbering existing files (overridden on a per-line basis when I actually want to clobber). - Exit the script at the first undefined and un-defaulted variable dereference. - Fail if any part of a pipeline fails. and shopt -s failglob - Treat a glob with no matches as an error. A bonus of using long names is that they are easy to search for online.
- rini17 6y agoI was once a shell newbie too, I can understand that. But, reinstalling a package every time? For the reason of robustness??
- rwbhn 6y ago> So I bit the bullet and figured out how to make (actually, adapt) a Dockerfile. Now, all of my CI builds will start with Hugo and lftp already installed. I read that as the original reason for the reinstall everytime was not yet knowing how to build their own docker image. A reasonable place for a newbie to be. And a perfectly reasonable step to leave for future optimization.