[Top][All Lists]

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

[bug] Bind + readline state corruption

From: Hans Kristian Otnes Berge
Subject: [bug] Bind + readline state corruption
Date: Tue, 5 Jul 2022 18:37:46 +0100

From: hanskoberge@gmail.com
To: bug-bash@gnu.org
Subject: [bug] Bind + readline state corruption

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux 46026 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11
14:32:00 PST 2021 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.1
Patch Level: 16
Release Status: release


    When modifying READLINE_LINE the substitution works but when returned
to the command line, either bash or the tty has lost its state so further
attempts to edit the command results in literal control characters being
output (self-inserted) without having any other effect. A good state is
restored on the following command line. I have found a work-around so the
problem can be investigated by observing the difference in state.


    I tested this in the newest head from devel

    Using readline within bind -x command.

    bind -m vi-insert -x '"\C-b": _RLL="${READLINE_LINE}";
_RLP="${READLINE_POINT}"; _RES=$(read -e -p "Text to insert: " text ; echo
${text}); READLINE_LINE="${_RLL:1:${_RLP}}${_RES}${_RLL:${_RLP}}";
READLINE_POINT=$(( ${#_RES} + ${_RLP} )); ';

    Then try arrow keys or control characters and see they are
self-inserted with no effect.
    (I have tried Windows Terminal and an older version of konsole (KDE).)
    The effect stops after 1 input line.


    The following seems to fix the issue for me.

    bind -m vi-insert -x '"\C-b": BINDX_TTY_STATE=$(stty -g);
_RLL="${READLINE_LINE}"; _RLP="${READLINE_POINT}"; _RES=$(read -e -p "Text
to insert: " text ; echo ${text});
${#_RES} + ${_RLP} )); stty $BINDX_TTY_STATE; unset BINDX_TTY_STATE;';

reply via email to

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