title: set -e does not respect logical not
body: <p>In several shells, the logical not (!) will "invert" the return code of a program. </p>
  
  <p>However, in a shell script with <code>set -e</code>, the logical not seems to cause the program to in fact never fail. Why is this? </p>
  
  <p>Tested in <code>bash</code>, <code>zsh</code>, and <code>ksh</code> with the same results.</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ cat test.sh 
  set -ex
  
  # setup
  touch myfile
  
  # observe available files
  ls .
  
  # succeeds
  ls myfile; echo $?
  
  # this succeeds as expected
  ! ls notafile; echo $?
  
  # why does this not exit when the return code is clearly non-zero?
  ! ls myfile; echo $?
  
  # this exits as expected when there is a non-zero return code
  ls notafile; echo $?
  
  # becasue we exit just above, this never get executed
  echo "test passed"
  </code></pre>
  
  <p>Results:</p>
  
  <pre class="lang-sh prettyprint-override"><code>bash test.sh 
  + touch myfile
  + ls .
  myfile  test.sh
  + ls myfile
  myfile
  + echo 0
  0
  + ls notafile
  ls: cannot access 'notafile': No such file or directory
  + echo 0
  0
  + ls myfile
  myfile
  + echo 1
  1
  + ls notafile
  ls: cannot access 'notafile': No such file or directory
  </code></pre>