On 11/21/25 8:52 AM, Christian Zuckschwerdt wrote:
Using readline-8.3 (with bash-5.3_p3 or bash-5.2_p37) there seems to be a 
history-search-backward regression inserting stray partial lines into the 
history.
It does not occur with readline-8.2_p13 (with bash-5.2_p37). Other functions 
(like history-search-forward) might also trigger this.

I did a lot of work between bash-5.2 and bash-5.3 to make the behavior of
non-incremental searches, incremental searches, and history traversal
(previous-history/next-history) more consistent.

The behavior of non-incremental searches in bash-5.3 is consistent with
how non-incremental searches behave. I got bug reports saying that
non-incremental searches would `drop' undo lists and modified lines, so
the current version uses the same underlying functions when performing
incremental and non-incremental searches to preserve modified history
lines consistently.


Example:
On a system with readline-8.3, e.g. Debian Sid (tested on 
debian-sid-genericcloud-amd64-daily-20251120-2302)

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 Ctrl-K "w" PgUp Enter
(or) Up Esc-BkSp "w" PgUp Enter
-> echo world
Exit (Ctrl-D)
But now there is a truncated "echo w" entry in .bash_history (possibly replacing 
"echo hello“, I guess)

No, the kill-line or the backwards-kill-word causes the modified line to
be copied into the readline editing buffer, given an undo list, and made
available for further editing.

If you were to use ^Recho w^R in place of page up (you have to do it twice
because incremental search will start on the current line instead of
immediately using previous history entries), you'd get the same result.

How can I investigate this further? Are there incremental change sets between 
8.2 and 8.3 to bisect?

The relevant CHANGES entry is in the bash-5.3-beta distribution:

e. Fix to make non-incremental searches use undo lists and set the history
   position the same way as incremental searches.


If you want to investigate for yourself, use the bash devel branch on
savannah.gnu.org (start at https://cgit.git.savannah.gnu.org/cgit/bash.git/?h=devel).


--
``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/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to