7 ms·
The one thing that people who understand bash have in the forefront of their minds is error handling. You can be a wizard in bash if nothing ever goes wrong.
by gorgoiler 5y ago
The one thing that people who understand bash have in the forefront of their minds is error handling.
You can be a wizard in bash if nothing ever goes wrong. Functions calling functions calling functions. It’s basically programming.
Until something goes wrong. Then there’s nothing you can do.
Anyone who has ever set-dash-ee’d and then seen a function execute without set-dash-ee when used in an if context knows what I mean.
- xg15 5y agoThat's why the cool kids today use set -euo pipefail. Or set -x if you're debugging.
- naniwaduni 5y agoThat ... doesn't solve the problem GP is noting.
- gorgoiler 5y agoYou may have missed my point. Set -e is not global. It only applies in some cases. In other contexts (inside a function when called as if <function>) errors will not be caught and once you realise that you realise there’s no hope of writing error proof logic in bash.
- xg15 5y agoAh, I'm sorry. I didn't realize the problem with functions and indeed misunderstood. I mean, while it's amazing what you can do with bash, I'd be wary to use it for "production" stuff. So far, I mostly used it for "toolbox" type if stuff that is only supposed to be used by the devs. For that purpose, it worked well though.