Bug 280889

Summary: bin/sh: `set -o vi` in .profile has no effect
Product: Base System Reporter: Ed Maste <emaste>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: bapt, gert, jlduran
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=215958

Description Ed Maste freebsd_committer freebsd_triage 2024-08-17 18:13:21 UTC
With `set -o vi` in .profile when I login I can see that the option should be set:

$ set -o | grep -w vi
vi              on

but it is not functional - ESC-K does nothing. Explicitly setting it again on the commandline works - ESC-K recalls the previous line for editing.

Main as of c7bc30c24f8625c6e9ef41be427fa26c6eb3d2bf
Comment 1 Ed Maste freebsd_committer freebsd_triage 2024-08-18 20:13:15 UTC
This is caused by the bind commands that exist by default in .~/shrc, e.g.

# csh like history on arrow up and down
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history

With these commands commented out `set -o vi` in .profile functions as expected. This is the same sort of issue described in PR215958.

If I call histedit() unconditionally in bindcmd the problem is avoided. Perhaps individual bind commands undo the effect of `el_set(el, EL_EDITOR, "vi")`?
Comment 2 Gert Doering 2024-09-12 15:13:47 UTC
Thanks for this PR - this has been annoying me for quite a while but I never came around to actually open a PR on it.

With the "bind" hint, what I came up was "would it work if I move the 'set -o vi' command to the end of '.shrc'" - and lo and behold, it works :-)