title: Aborting a shell script if any command returns a non-zero value
body: <p>I have a Bash shell script that invokes a number of commands.</p>
  <p>I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value.</p>
  <p>Is this possible without explicitly checking the result of each command?</p>
  <p>For example,</p>
  <pre><code>dosomething1
  if [[ $? -ne 0 ]]; then
      exit 1
  fi
  
  dosomething2
  if [[ $? -ne 0 ]]; then
      exit 1
  fi
  </code></pre>