[Top][All Lists]

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

Re: readline: How to unbind _all_ keys

From: Koichi Murase
Subject: Re: readline: How to unbind _all_ keys
Date: Wed, 22 May 2019 21:58:27 +0900

> What still remains is the not working assignment of ^X.
> Henning

Hi, I guess you are using Bash 4.4 because, according to my records,
bind -x '"\C-x": ...' after unbinding all the keyseqs causes segfaults
in Bash-3.0, 3.1 and 4.0--4.2, infinite loops in Bash 3.2, and error
messages like "bash_execute_unix_command: ..." in Bash 4.4. It just
works with Bash 4.3 and 5.0+.

a. The easiest way is to switch to Bash 5.0 because it also contains
several other fixes on key bindings. For example, bind -x '"\C-@":
command'  doesn't work in Bash 4.4.

b. If you want to support older Bash, the second easiest way is to use
vi editing-mode using a setting such as "set -o vi" or "bind 'set
editing-mode vi'" before unbinding/binding. There are no problems with
C-x in the vi-insert keymap.

c. If you have to use the emacs editing-mode for some reason, the
third option might be something like the following (if you are using
UTF-8 encoding):

bind -s '"\C-x": "\xC0\x98"'
bind -x '"\xC0\x98": shell-command'

But there is sometimes a delay to receive C-x with this workaround (I
forgot the condition that the delay occurs). [ Note: \xC0\x98 is a
2-byte UTF-8 representation of \C-x (0x18). Usually non-canonical
representation of UTF-8 is considered unsecure if you want to filter
out some input sequences containing \C-x (0x18) because this
non-canonical representation may pass through such filters. But, if
you do not filter sequences containing C-x, you can use this
workaround. ].


reply via email to

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