[Top][All Lists]

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

bind -x and multiple prompt/command lines

From: Rob Foehl
Subject: bind -x and multiple prompt/command lines
Date: Mon, 14 Apr 2014 02:02:18 -0400 (EDT)
User-agent: Alpine 2.10 (LFD 1266 2009-07-14)

When executing shell commands bound to key sequences with bind -x, the initial line(s) of multiple line shell prompts and/or commands are left intact; when the prompt is redisplayed, the initial line(s) are output again, causing the appearance of duplicate lines. This seems to be due to the code to clear the current (last) line in bash_execute_unix_command in bashline.c, which also seems to be the only place where the line is cleared in this fashion.

A minimal test case:

do_nothing () { :; }
bind -x '"\C-k": do_nothing'

Then compare the result of pressing C-k at the prompt when PS1 expands to a single line vs. multiple lines, like '\u$ ' and '\u\n$ ' . The same thing happens with input lines long enough to wrap, and at least there is inconsistent with other actions that clear the input line.

I've confirmed this with 4.3.11(7)-release built from git commit b7ec181 (current as of this writing), as well as several patch levels of 4.2 as shipped by various Linux distributions.

Does readline know enough about where a multi-line prompt starts to be able to clear and redisplay the whole thing? I'm not familiar with the code, but from a quick read it seems like that capability would be necessary to change this behavior. I'm curious about this because I'm looking for ways to do more advanced command rewriting than completion permits, and the READLINE_LINE facility has some potential...


reply via email to

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