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
F18823817: D20556.diff
Thu, Oct 23, 1:28 PM
F18812800: D20556.id49041.diff
Mon, Oct 20, 12:28 PM
F18786997: D20556.diff
Tue, Oct 14, 9:25 PM
F18736761: D20556.id49039.diff
Wed, Oct 1, 7:45 AM
F18653449: D20556.diff
Sep 21 2025, 1:35 PM
F18605828: D20556.diff
Sep 13 2025, 9:25 PM
F18570277: D20556.id49041.diff
Sep 10 2025, 3:19 AM
F18570276: D20556.id49039.diff
Sep 10 2025, 3:19 AM
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
Branch
vivim1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 22912
Build 31433: Run Core Tests
Build 31432: arc lint + arc unit