How to tell if any command in bash script failed (non-zero exit status) : <p>I want to know whether any commands in a bash script exited with a non-zero status.</p>

<p>I want something similar to <code>set -e</code> functionality, except that I don't want it to exit when a command exits with a non-zero status.  I want it to run the whole script, and then I want to know that either:</p>

<p>a) all commands exited with exit status 0<br>
-or-<br>
b) one or more commands exited with a non-zero status</p>

<p><br/>
e.g., given the following:</p>

<pre><code>#!/bin/bash

command1  # exits with status 1
command2  # exits with status 0
command3  # exits with status 0
</code></pre>

<p>I want all three commands to run.  After running the script, I want an indication that at least one of the commands exited with a non-zero status.</p>
