HomePhabricator

If "vi" or "vim" exit with an error code, test for error-on-interactive-mistake…

Description

If "vi" or "vim" exit with an error code, test for error-on-interactive-mistake behavior

Summary:
See T13297. Some versions of "vi" and "vim" exit with an error code if the user makes a command typo while performing an interactive edit. This can lead to discarding stuff they typed.

If we receive an error code:

  • test if the binary is "vi" or "vim";
  • if it is, test if "<binary> +q +Q" exits nonzero;
  • if it does, ignore the error code.

This appears to be a conclusive test for "error indicates interactive command mistake".

Test Plan:

  • On my system, ran EDITOR=... arc diff --trace with vi and vim.
  • Made an intentional command typo, e.g. :Q<enter> in command mode.
  • Saved with :wq.
  • Before, vim: worked fine.
  • After, vim: worked fine.
  • Before, vi: failed after vi exited with an error.
  • After, vi: detected the error in vi, detected questionable vi binary behavior, workflow recovered and succeeded.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20556