set -e
myfunc() {
date %x # syntax error; returns 1, should be +%x
echo 'should not get here'
}
if var=$(myfunc); then
echo $var # erroneously prints 'should not get here'
else
echo failed
fi
Then you will ignore failure, which is bad.This is a variant of the issue that the sibling comment brought up -- error handling is disabled inside "if" conditions.
In Oil the whole construct is unconditionally disabled by strict_errexit. It's too subtle.
Oil has 2 ways of capturing the exit code, including
run --assign :status -- mycommand # exit 0 but assign the status to a var
and shopt --unset errexit { # explicitly disable error handling if you want
mycmd
var status = $?
}
I'm looking for feedback to make sure that Oil has indeed fixed all of this stuff: https://www.oilshell.org/blog/2020/10/osh-features.htmlBasically the situation is "damned if you do and damned if you don't" in Bourne shell, so you need language/interpreter changes to really fix it. The rules are too tricky to remember even for shell experts -- there are persistent arguments on POSIX behavior that is over 20 years old, simply because it's so confusing.