On 12/4/25 3:11 PM, Christian Zuckschwerdt wrote:
Here are my findings on: using history-search-backward (PgUp) will commit the incomplete line to the history.
See my previous reply for the reason that the history list contains edited lines. I don't think you can describe them as `incomplete' -- they are in the state you left them.
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
In this case, bash didn't add any history entries, so there's nothing to append -- it simply writes the history list to the history file, including any entries you edited. Any program that uses write_history() will exhibit the same behavior.
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()
It's called for every history traversal: previous-history/incremental search/non-incremental search (both when prompting for a search string and searching for a string already on the line).but in this case it feels like _rl_maybe_replace_line() should be called after _rl_previous_history_internal() has loaded the history entry?
No, that discards the undo list we are trying to preserve here.
My advice is to try the revert-all-at-newline variable and see if it does
what you want.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
