Bug 280889 - bin/sh: `set -o vi` in .profile has no effect
Summary: bin/sh: `set -o vi` in .profile has no effect
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-17 18:13 UTC by Ed Maste
Modified: 2024-09-12 15:13 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 :-)