tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
set -e again
I discovered the following today.
This:
set -e
f() {
echo foo
false
echo bar
}
f
as one might expect, prints "foo" and exits.
However, this:
set -e
f() {
echo foo
false
echo bar
}
f || echo baz
echo buzz
prints "foo", "bar", "buzz", and continues. Furthermore, all the
shells I have in easy reach agree on it.
This seems wrong - the exit status of the f is guarded, but the false
is not. But also, the fact that everybody agrees makes me think it's
probably the agreed result of the last round of POSIX wrangling over
the -e definition some years back.
Is this intended, and is there a way to get the user's intended
behavior of exit on unchecked failure back? (E.g. is there a different
set to get functions to return on unchecked failure that might cover
this?)
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index