Here are my findings on: using history-search-backward (PgUp) will commit the incomplete line to the history.
To recap what I'm seeing: On a system with readline-8.3, and using Bash as an example: Start with a .bash_history containing only echo hello echo world And /etc/inputrc containing (at least) "\e[5~": history-search-backward Open a shell Up Up Enter -> echo hello Up Esc-Left "w" PgUp Enter -> echo world Exit (Ctrl-D) But now there is a intermediate line "echo whello" entry in .bash_history $ cat .bash_history echo hello echo world echo whello echo world I have traced this as follows: - on a line of "echo whello" with the point after the "w" - rl_history_search_backward() is invoked - rl_history_search_internal() is called - make_history_line_current() is called - rl_get_previous_history() is called - _rl_maybe_replace_line() is called - the line is still "echo whello" which is placed in the history - _rl_previous_history_internal() is called to load the actual history entry (of "echo world") Also rl_get_next_history() has this same "_rl_maybe_replace_line() then _rl_next_history_internal()" order of calls. I'm not sure of other uses (incremental search) of rl_get_previous_history() but in this case it feels like _rl_maybe_replace_line() should be called after _rl_previous_history_internal() has loaded the history entry? That change of call order fixes the above test case and the history now looks as expected: $ cat .bash_history echo hello echo world echo hello echo world thanks, Christian
