title: Why is trap command not seeing exit code?
body: <p>Im having issues where the <code>EXIT Trap</code> command is not seeing my <code>exit</code> code. Ive tried just setting a <code>$var</code> from <code>0</code> to <code>1</code> and right now I'm trying to override the <code>exit</code> with a <code>1</code> and base on that having the <code>trap</code> command run certain code.</p>
  
  <pre><code>#!/bin/bash
  
  if [[ 0 -ge 1 ]]; then
      echo "run code"
  else
      echo "oops.. dont like what I see"
      exit 1
  fi
  
  finish() {
      sleep 5
      term=$?
      if [[ $term -eq 0 ]]; then
          echo pass
      else
          echo fail
      fi
  }
  trap 'finish' EXIT
  </code></pre>
  
  <p>When I troubleshoot the code. <code>term</code> is being assign to <code>0</code> when <code>exit</code> is triggered. </p>