Fix error handling.

The function called within the if would not actually apply errexit. By calling
the function within a subshell, we are still able to survive to capture the
exit code and the function is called with errexit enabled.