Re:Shell Script Best Practices, from a decade of scripting t...
by stephan-cr on Saturday October 29, 2022 @04:49AM
(#33382227)
> The biggest Issue is that error handling is completely broken in POSIX shell scripting (including Bash). Even errexit doesn't work as any normal language would implement it (One could say it is broken by design).
I guess you're referring to http://mywiki.wooledge.org/BashFAQ/105. Got recently hit by these as well.
Re:Shell Script Best Practices, from a decade of scripting t...
by arendtio on Saturday October 29, 2022 @06:37PM
(#33388655)
Yes and my personal favorite: Functions can behave differently depending on, if they are being called from a conditional expression vs. from a normal context. Errexit has no effect if the function is called from a conditional expression.
So if you don't care about error cases everything is fine, but if you do, it gets ugly really fast. And that is the reason why other languages are probably be better suited if you want to write something bigger that 10 lines.
However, I have to admit, I don't follow that advice myself...