Hi Chet,

Sorry. I realized that I didn't understand what "revert-all-at-newline" is
doing. I checked the manual, it says:

       revert-all-at-newline (Off)
              If set to On, readline will undo all changes to history lines
              before returning when accept-line is executed.  By default,
              history lines may be modified and retain individual undo lists
              across calls to readline.

According to the description, I set it to "On" and tried the following
steps in bash:

1. Type "echo 5566" and hit "enter"
2. Hit "up" to navigate to the history "echo 5566"
3. Change it to "echo 7788" and DON'T hit "enter"
4. Hit "down" to navigate to an empty place
5. Type "ls" and hit "enter"
6. Type "history | tail -n 3" and hit "enter"

After that, I expected that I can see the history "echo 5566" in the last
command since it should be reverted. However, I still see "echo 7788" in
the results:

    $ history | tail -n 3
      501* echo 7788
      502  ls
      503  history | tail -n 3

What did I miss? Thank you.

Best,
John Lin

Chet Ramey <[email protected]> 於 2019年1月30日 週三 下午11:12寫道:

> On 1/29/19 2:59 AM, 林自均 wrote:
> > Hi Chet,
> >
> > Thank you for the explanation. I tried "revert-all-at-newline", but it's
> > not what I wanted. What I wish is:
> >
> > 1. Use arrow key to navigate to a history command (e.g., "echo 5566").
> > 2. Modify the command (e.g., change to "echo 7788").
> > 3. Instead of hitting enter to execute it, use arrow keys to navigate to
> > other commands.
> > 4. Ctrl+C
> > 5. The history is NOT modified (i.e., "echo 5566" WON'T BE CHANGED to
> "echo
> > 7788").
> >
> > Is that possible?
>
> What I wrote is accurate: "This is  pretty well baked in to how readline
> operates." The history editing and undo list behavior is a fundamental part
> of readline, and there isn't a way to completely disable it. The
> `revert-all-at-newline' option is the way to undo its effects after the
> fact, but that doesn't get invoked when you interrupt readline's processing
> with SIGINT.
>
> --
> ``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/
>
_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline

Reply via email to