title: What is the correct way to use the bash if else && || shortcut?
body: <p>I have come across some strange behavious (well probably not strange but I don't understand it !)</p>
  
  <p>I want to write some if / e,se statements using the bash shorthand syntax:</p>
  
  <pre><code>[[ 1 -eq 1 ]] &amp;&amp; echo "true" || echo "false"
  </code></pre>
  
  <p>The output of the above code gives:</p>
  
  <pre><code>true
  </code></pre>
  
  <p>Now the code above actually works fine. But this next code does not:</p>
  
  <pre><code>[[ 1 -eq 1 ]] &amp;&amp; infMsg "true" || infMsg "false"
  </code></pre>
  
  <p><em>infMsg</em> is just a function. The output from the above code gives:</p>
  
  <pre><code>true
  false
  </code></pre>
  
  <p>I only want it to say 'true'.</p>
  
  <p>Is there something I am missing in the way the &amp;&amp; || syntax handles exit codes from functions ?</p>