Skip to content
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

Defaulting to set -e might not be great.... #1

Open
espoelstra opened this issue Aug 9, 2018 · 1 comment
Open

Defaulting to set -e might not be great.... #1

espoelstra opened this issue Aug 9, 2018 · 1 comment

Comments

@espoelstra
Copy link

Articles questioning its use and highlighting the MANY pitfalls of using it:
http://mywiki.wooledge.org/BashFAQ/105

Specifically many of the examples:
http://mywiki.wooledge.org/BashFAQ/105#Exercises
The list of caveats is a mile long:
http://fvue.nl/wiki/Bash:_Error_handling

Here are some "positive" or at least not negative examples suggesting using it (in a simple manner), but I think trap and explicit error handling is far better than hoping set -e saves you.

https://www.davidpashley.com/articles/writing-robust-shell-scripts/#id2596016 http://redsymbol.net/articles/unofficial-bash-strict-mode/

@espoelstra
Copy link
Author

I have since been educated a little more in how set -e can be useful, but having set -o pipefail and potentially adding a good basic trap aTrapFunction ERR could also be useful to provide some output to the user/script writer when they trigger the -e and it exits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant