Page MenuHomePhabricator

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

Authored by epriestley on May 24 2019, 8:34 PM.
Tags
None
Referenced Files
F15543612: D20556.id.diff
Fri, Apr 25, 11:47 PM
F15487665: D20556.id49039.diff
Thu, Apr 10, 4:00 PM
F15486947: D20556.id49041.diff
Thu, Apr 10, 10:04 AM
F15472273: D20556.id.diff
Apr 5 2025, 12:20 PM
F15470159: D20556.diff
Apr 4 2025, 8:53 PM
F15450240: D20556.diff
Mar 28 2025, 2:41 PM
F15443348: D20556.diff
Mar 27 2025, 3:55 AM
F15417399: D20556.id49041.diff
Mar 20 2025, 4:51 PM
Subscribers
None
Tokens
"Baby Tequila" token, awarded by avivey.

Details

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.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable