shlib.sh: Record the true error code when bang commands fail
commitd542b135b7137ea104d0ac8b36db4f8927dd837b
authorKyle J. McKay <mackyle@gmail.com>
Mon, 2 Dec 2013 06:10:21 +0000 (1 22:10 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Mon, 2 Dec 2013 06:10:21 +0000 (1 22:10 -0800)
tree4fe87e4b40a20d7b33167b3438ba7435d1ac7628
parentf05c450d3fd6463e3a39a3cc40201b6015bfe015
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.
shlib.sh