Re:The Bourne shell lets you set variables in if expressions
by andsens on Saturday May 15, 2021 @09:03AM
(#27164828)
It's worse than that actually, `set -e`/"errexit" is disabled for function calls in ifs. Meaning this:
will output
[ Parent
| on HN ]
Re:The Bourne shell lets you set variables in if expressions
by jbrot on Saturday May 15, 2021 @09:47AM
(#27165190)
Yep, likewise it’s also disabled in function calls and sub shells that are invoked in an && or || block (i.e., in the above case of you change the if statement to “fn && echo ...” you’ll see the same behavior).
Even worse, you can add the line “set -e” inside the function explicitly re-enabling it and it still won’t change the outcome because errexit wasn’t technically unset!
Re:The Bourne shell lets you set variables in if expressions
by chubot on Saturday May 15, 2021 @12:41PM
(#27166731)
Yes, Oil fixes this with strict_errexit:
sibling comment: https://news.ycombinator.com/item?id=27166719
blog post: https://www.oilshell.org/blog/2020/10/osh-features.html
It needs some official documentation, but if you download Oil and see any other problems I'm interested! I think I fixed all of them.