title: How to trap exit code in Bash script
body: <p>There're many exit points in my bash code. I need to do some clean up work on exit, so I used trap to add a callback for exit like this:</p>
  
  <pre><code>trap "mycleanup" EXIT
  </code></pre>
  
  <p>The problem is there're different exit codes, I need to do corresponding cleanup works. Can I get exit code in mycleanup?</p>