title: Why does vim, run as the alias "vi", return a non-zero exit code when any error happened?
body: <p>On my system (Mac OS X), <code>vi</code> is aliased to <code>vim</code>. However, when run as <code>vi</code>, the behavior of its exit code is different: it will return a non-zero exit code when any error happened during the session, as can be seen by the following test:</p>
  
  <ul>
  <li>In a terminal, open any file with vim.</li>
  <li>Do some editing.</li>
  <li>Try to exit using <code>:q</code>. This should result in an error (No write since last change).</li>
  <li>Exit anyway using <code>:q!</code> or <code>:wq</code>.</li>
  <li>Type <code>echo $?</code> in the terminal.</li>
  </ul>
  
  <p>The return code will be 0 if I used <code>vim</code> in the first step to open vim, but will be 1 if I used <code>vi</code>.</p>
  
  <p>This problem is probably the root cause of <a href="https://stackoverflow.com/questions/41719802/vi-is-aliased-to-vim-but-exit-with-code-1">Vi is aliased to vim but exit with code 1</a>.</p>