title: Linux trap best practices for &&
body: <p>Using <code>trap</code> may help in writing cleanest bash script. 
  However I would like to know whether a solution exists in order to trap an error in the following case:</p>
  
  <p>GNU bash, version 4.2.45</p>
  
  <p>case OK</p>
  
  <pre><code>#!/bin/bash
  trap 'echo OK i see error at line $LINENO;exit' ERR 
  unknowncommand
  echo "test KO should never reach me"
  </code></pre>
  
  <p>case KO</p>
  
  <pre><code>#!/bin/bash
  trap 'echo OK i see error at line $LINENO;exit' ERR
  unknowncommand &amp;&amp; echo "miss the trap"
  echo "test KO should never reach me"
  </code></pre>
  
  <ul>
  <li>Unfortunately we reach the last sentence as if <code>&amp;&amp;</code> make the whole sentence not an ERR.</li>
  </ul>