title: Bash ERR signal not trapped in procedures?
body: <p>Consider the following code:</p>
  
  <pre><code>#!/bin/bash
  
  trap 'echo "ERROR" &amp;&amp; exit 2' ERR
  
  proc(){
     false
     return 0
  }
  echo START
  
  proc
  
  echo END
  </code></pre>
  
  <p>The above shows output</p>
  
  <pre><code>START
  END
  </code></pre>
  
  <p>but I would expect the <strong>false</strong> command to trigger the trap procedure for the ERR signal.</p>
  
  <p>If I put <strong>false</strong> instead of the call to <strong>proc</strong> the signal is triggered and output</p>
  
  <pre><code>START
  ERROR
  </code></pre>
  
  <p>is shown as expected. If I put the <strong>trap</strong> command again at the beginning of <strong>proc</strong> procedure, it is again being correctly trapped.</p>
  
  <p>How is it so that trapping only works outside of procedures, unless <strong>trap</strong> command is repeated in the procedure? I could not find any documentation on that.</p>
  
  <p>I got the same behavior on bash versions 3.1.0, 3.2.25, 4.1.17 .</p>