Fix and clean up `fail` function

The `fail` function was checking its arguments incompatibly with the
shell option NO_UNSET; fix that, and clean up the function’s
definition.