I think this is a bug of some sort in rlwrap or readline rather than in tmux.

It looks like rlwrap isn't actually writing anything to the terminal after the
first ESC k.

Running tmux with -vvvv, I get (the ^M is me pressing enter at the end of
"rlwrap cat"):

keys are 1 (^M)
writing key 0xd
-- c0 1: 13
-- c0 2: 13
-- c0 3: 10
-- c0 1: 13
-- c0 2: 13
-- sq 5: 75 (K): 0 [sx=81, sy=48, cx=0, cy=5, ru=0, rl=47]
-- c0 6: 13
keys are 1 (^[)
keys are 2 (^[k)
writing key 0x206b
-- c0 1: 13
-- c0 1: 13
-- sq 1: 75 (K): 0 [sx=96, sy=30, cx=0, cy=1, ru=0, rl=29]
-- c0 1: 13
keys are 1 (k)
writing key 0x6b
-- ch 1: 102 (f)
-- ch 2: 114 (r)
-- ch 3: 111 (o)
-- ch 4: 98 (b)
-- c0 5: 13

So on pressing ESC k for the first time it just sends two carriage returns and
\\033[K which is EL 0 (erase to end of line) followed by another CR. So tmux is
correct not to show anything until the second "k" keypress when rlwrap sends
"frob".

Running rlwrap in script(1) inside tmux or screen and doing the same (ESC k
followed by k) shows the same output:

rlwrap cat^M^M
^M^M^[[K^M^M^M^[[K^Mfrob^M^M

But if I run it in script(1) inside xterm with TERM=screen and again press ESC
k followed by a second k:

TERM=screen rlwrap cat^M^M
^M^M^[[K^M^M^M^[[K^Mfrob^M^[[1Pbar^M^M

There is nothing odd about this sequence and it works fine in tmux - if you
send "^M^M^[[K^M^M^M^[[K^Mfrob^M", it correctly prints frob. So rlwrap or
readline must be sending ""^M^M^[[K^M" and then incorrectly requiring a second
key press before sending the rest of the data.

I wonder if it is doing anything funny with termios, although I can't see why
it would possibly need to for something as simple as this.

I think you should speak to upstream about this. Feel free to let me know if
they need any other information.


On Sun, Jan 10, 2010 at 09:37:03PM +0000, Nicholas Marriott wrote:
> Hi
> 
> I can reproduce this behaviour inside tmux (AND in screen) running in xterm,
> although oddly not outside even with TERM=screen. I'll look into it.
> 
> 
> On Sun, Jan 10, 2010 at 09:48:33PM +0100, Matthias Kilian wrote:
> > On Mon, Jan 11, 2010 at 01:07:15AM +0500, Alexandr Shadchin wrote:
> > > > This update package rlwrap to the latest release 0.35.
> > > > Tested on i386 and amd64.
> > > > 
> > > > Comments ? OK ?
> > > > 
> > > 
> > > Forgot patches
> > 
> > Unfortunately, this doesn't work well in vi-mode within tmux within
> > an xterm: if I run the new rlwrap on cat (with a non-empty
> > ~/.cat_history) and start to scroll back in the history (using ESC
> > k), an empty line is displayed by rlwrap (instead of the last line
> > of the history). If I scroll back further (using ESC k a second
> > time), the *last* line of the history is displayed instead of the
> > second-last one, and so on. If I then hit return, the display
> > switches to the correct history line.
> > 
> > For example, if ~/.cat_history contains
> > 
> >     foo
> >     bar
> >     frob
> > 
> > you'll get (for rlwrap cat):
> > 
> > - an empty line after the first ESC k
> > - `frob' after the second ESC k
> > - `bar' after the third ESC k
> > - `foo' after a return
> > 
> > (and after a second return this `foo' is passed to cat)
> > 
> > This doesn't happen with rlwrap-0.28. I'm not sure wether this is
> > a problem of rlwrap or tmux.
> > 
> > Ciao,
> >     Kili
> > 
> 

Reply via email to