bug-bash
[Top][All Lists]
Advanced

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

Re: bash_execute_unix_command: cannot find keymap for command


From: Chet Ramey
Subject: Re: bash_execute_unix_command: cannot find keymap for command
Date: Wed, 07 Jul 2010 22:32:15 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 7/4/10 5:14 PM, Michał Kazior wrote:
> Hello,
> 
> What I'd like to do is to bind a function to a key sequence (not a
> single-byte one - e.g. F1, Arrow Up, etc.).
> 
> One would try:
> 
> hello() { echo world; }
> bind -x '"ab": hello'
> 
> The above works if typed "ab". But then:
> 
> hello() { echo world; }
> bind -x '"abc": hello'
> 
> does not and prints (when "abc" is typed):
> 
> ./script: line 6: bash_execute_unix_command: cannot find keymap for command

Yeah, this is a problem without a clean solution.

Readline implements multi-character key sequences using a chain of keymaps.
(This is how "ab", "abx", and "abc" can all be bound to different things.)
When it dispatches to the bound function, bash_execute_unix_command here,
the function has access only to the first keymap in the chain and the last.

Bash implements `bind -x' by keeping a parallel set of keymaps holding the
command to be invoked as a macro.  The readline key sequence resolves to
bash_execute_unix_command.

You can see the problem.  For key sequences longer than two characters,
bash_execute_unix_command doesn't have any good way to follow the chain
of keymaps to find the right command.  It knows only the first keymap,
the final keymap, and the key in the final keymap.

There is one good way to fix it, but it requires changing the readline
external interface, which will have to wait until the next major version
is released.  There is probably a clumsy way to do it now, but the code
doesn't implement it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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