[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Disable the "modify history with arrow keys" feature

From: Chet Ramey
Subject: Re: [Bug-readline] Disable the "modify history with arrow keys" feature
Date: Sat, 2 Feb 2019 15:36:35 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.0

On 2/1/19 8:57 PM, 林自均 wrote:
> Hi Chet,
> For Frederick's problem, I suppose that is a bug. Here is my proposed patch
> (against bash code base):
>     diff --git a/lib/readline/misc.c b/lib/readline/misc.c
>     index 64b1457d..6aed8e64 100644
>     --- a/lib/readline/misc.c
>     +++ b/lib/readline/misc.c
>     @@ -446,7 +446,8 @@ _rl_revert_all_lines (void)
>        saved_undo_list = rl_undo_list;
>        hpos = where_history ();
>     -  entry = (hpos == history_length) ? previous_history () :
> current_history ();
>     +  history_set_pos (history_length);
>     +  entry = previous_history ();
>        while (entry)
>          {
>            if (ul = (UNDO_LIST *)entry->data)
> The root cause was that the variable "entry" should have pointed to the
> latest history entry, but it pointed to the current history instead. If I
> am missing anything, please let me know. Thanks.

This is the correct diagnosis, but I am not sure this is the right place
to fix it. The function does exactly what the comment says it should:
revert all lines before the current history entry. If the caller wants it
to act on every history line, it should ensure that the history position
is at the end before calling it (history_offset == history_length).  I'll
make the fix in readline_internal_teardown() (patch attached).

Thanks for looking at it.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

Attachment: readline-revert-lines.patch
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]