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

Bug#913237: xterm: exec-formatted yields a tilde character in zsh and emacs



On 2018-11-26 20:38:37 -0500, Thomas Dickey wrote:
> On Sun, Nov 25, 2018 at 12:08:03AM +0100, Vincent Lefevre wrote:
> > With zsh, one can reproduce the issue with:
> > 
> > $ xterm -e zsh -f
> 
> If you added a "-l" option, that would turn on xterm's logging feature
> 
> 	xterm -l -e zsh -f
> 
> which could be interesting.

Here's what the log file gives (output with hd):

00000000  1b 5b 31 6d 1b 5b 37 6d  25 1b 5b 32 37 6d 1b 5b  |.[1m.[7m%.[27m.[|
00000010  31 6d 1b 5b 6d 20 20 20  20 20 20 20 20 20 20 20  |1m.[m           |
00000020  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000060  20 20 20 20 0d 20 0d 0d  1b 5b 6d 1b 5b 32 37 6d  |    . ...[m.[27m|
00000070  1b 5b 32 34 6d 1b 5b 4a  7a 69 72 61 25 20 1b 5b  |.[24m.[Jzira% .[|
00000080  4b 1b 5b 3f 32 30 30 34  68 62 08 62 69 6e 64 6b  |K.[?2004hb.bindk|
00000090  65 79 20 2d 65 1b 5b 3f  32 30 30 34 6c 0d 0d 0a  |ey -e.[?2004l...|
000000a0  1b 5b 31 6d 1b 5b 37 6d  25 1b 5b 32 37 6d 1b 5b  |.[1m.[7m%.[27m.[|
000000b0  31 6d 1b 5b 6d 20 20 20  20 20 20 20 20 20 20 20  |1m.[m           |
000000c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000100  20 20 20 20 0d 20 0d 0d  1b 5b 6d 1b 5b 32 37 6d  |    . ...[m.[27m|
00000110  1b 5b 32 34 6d 1b 5b 4a  7a 69 72 61 25 20 1b 5b  |.[24m.[Jzira% .[|
00000120  4b 1b 5b 3f 32 30 30 34  68 07 7e                 |K.[?2004h.~|
0000012b

The 07 7e is what the exec-formatted generates (the Ctrl-G doesn't
seem to have any effect in zsh).

If after "binkey -e", I type "echo '" then Ctrl-V, I get:

00000120  4b 1b 5b 3f 32 30 30 34  68 65 08 65 63 68 6f 20  |K.[?2004he.echo |
00000130  27 1b 5b 37 6d 5e 5b 1b  5b 32 37 6d 5b 32 30 31  |'.[7m^[.[27m[201|
00000140  7e                                                |~|

So, actually, the effect of exec-formatted is more complex than just
a tilde (or Ctrl-G tilde).

> But the bug report deals with programs run from xterm, which the
> shell wouldn't see -- unless it's reading xterm's output in some
> way.

The shell sees the tilde, as if it were entered with the keyboard.

Note that I can replace

  exec-formatted("browser %s", PRIMARY)

by

  exec-formatted("/bin/true", PRIMARY)

and I get the same behavior in xterm, i.e. the command doesn't matter.

> > then in the xterm:
> > 
> > zira% bindkey -e
> 
> Perhaps "zira%" is your shell prompt.

Yes, the hostname follwed by "%" is the default zsh prompt.

> What does "bindkey -e" have to do with exec-formatted?

"bindkey -e" selects Emacs editing mode. It just makes the issue
visible. But with the "echo '" + Ctrl-V test, the same issue is
reproducible without needing "bindkey -e":

00000000  1b 5b 31 6d 1b 5b 37 6d  25 1b 5b 32 37 6d 1b 5b  |.[1m.[7m%.[27m.[|
00000010  31 6d 1b 5b 6d 20 20 20  20 20 20 20 20 20 20 20  |1m.[m           |
00000020  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000060  20 20 20 20 0d 20 0d 0d  1b 5b 6d 1b 5b 32 37 6d  |    . ...[m.[27m|
00000070  1b 5b 32 34 6d 1b 5b 4a  7a 69 72 61 25 20 1b 5b  |.[24m.[Jzira% .[|
00000080  4b 1b 5b 3f 32 30 30 34  68 65 08 65 63 68 6f 20  |K.[?2004he.echo |
00000090  27 5e 08 1b 5b 37 6d 5e  1b 5b 37 6d 5b 1b 5b 32  |'^..[7m^.[7m[.[2|
000000a0  37 6d 5b 32 30 31 7e                              |7m[201~|
000000a7

The effect of exec-formatted is what appears after "27 5e 08".

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Reply to: