title: Add (collect) exit codes in bash
body: <p>I need to depend on few separate executions in a script and don't want to bundle them all in an ugly 'if' statement. I would like to take the exit code '$?' of each execution and add it; at the end, if this value is over a threshold - I would like to execute a command.</p>
  
  <p>Pseudo code:</p>
  
  <pre><code>ALLOWEDERROR=5
  
  run_something
  RESULT=$?
  ..other things..
  
  run_something_else
  RESULT=$RESULT + $?
  
  if [ $RESULT -gt ALLOWEDERROR ] 
     then echo "Too many errors"
  fi
  </code></pre>
  
  <p>Issue: Even though the Internet claims otherwise, bash refuses to treat the RESULT and $? as integer. What is the correct syntax?</p>
  
  <p>Thanks.</p>