shlib.sh: Record the true error code when bang commands fail
The exit code of an if statement is the last command executed by
either the then section or the else section (whichever applies) or
0 if no commands are executed. In order to examine the status of
a failed if command, it must be checked in the else section or it
will be too late.
The exit code of a pipeline is that of the last command in the
pipeline so when show_progress is in effect that would be the
result of the tee command which presumably usually succeeds.
Collect the status of non show_progress bang commands in the else
section and arrange to read the status of show_progress bang
commands into a variable to avoid losing it in the pipeline.