Hacker News new | ask | show | jobs
by koala_man 4156 days ago
The jury's still out on whether `set -e` is worth it.

On paper it sounds like it's equivalent to `on error goto 0`, making a script fail-fast -- which would have been awesome.

Instead, it makes a script fail sometimes for things that are sometimes errors. The rules for how and when are unexpected and unintuitive, several weird cases are described on http://mywiki.wooledge.org/BashFAQ/105

If enabling it just granted a free 50% chance of stopping on any given error, it would have been worth it, but it triggers on false positives as well.

1 comments

Well, dealing with horrible exception handling is still better than just silently running off the edge on errors.

Much like any language, you need to read and understand it to be able to truly write, I think. bash is deceptive in this regard IMO, due to how low its barrier to entry is.

Now if you want to see some truly horrible code, implement a shell script that runs in bash and zsh and does exception printing in both.