Understanding Bash short-circuiting
<p>First of all I'm not a Bash pro. I discovered few months ago that if I use both the <code>&amp;&amp;</code> and <code>||</code> short circuit operators in sequence with curly braces, then in case the first statement exits with a truthful value, if the last statement in the true block exits non-zero, then the fail block will be executed too. Like this:</p>

<pre><code>returnNumber 0 &amp;&amp; {
    echo 'OK'
    returnNumber 1
} || {
    echo 'NG'
}
</code></pre>

<p>Will output:</p>

<pre><code>OK
NG
</code></pre>

<p>So, I looked for the easiest solution for this, and came up with this:</p>

<pre><code>returnNumber 0 &amp;&amp; {
    echo 'OK'
    returnNumber 1
    :
} || {
    echo 'NG'
}
</code></pre>

<p>I know, it is easy to leave out the colon builtin, but is it a proper way for a workaround?</p>