You are not logged in.

#1 2014-06-04 10:14:39

izmntuk
Member
Registered: 2013-12-21
Posts: 12

A single-line 'echo' command freezes vte-based terminal emulator

Hello all. First post in NC and have a little question:

When I run this in my xfce4-terminal:

echo -en '\eP'

Um... It seems that the terminal emulator stucks and isn't usable any more. (Ctrl+C has no effect sad )
It's really strange... then I use xterm to run it -- without any problems.
However I didn't give up (just because of curiosity tongue) then I tested more terminal emulators (gnome-terminal, pantheon-terminal, lxterminal and even the terminal plugin in geany), they stucks.
I dunno why 'echo' could stuck the terminal emulator (bug in these terminal emulators?...). Does anyone have idea about this?

Edit:
It seems that this is an issue of vte. And as I now use rxvt-unicode and yakuake, this issue could be avoided smile .
See #3 for a temporary workaround.

Last edited by izmntuk (2014-10-24 06:08:38)


izmntuk@github: zshrc and tmux.conf

Offline

#2 2014-06-04 13:18:07

gay
Member
Registered: 2012-12-16
Posts: 93

Re: A single-line 'echo' command freezes vte-based terminal emulator

When the shell freezes after issuing this echo command, try hitting ESC a number of times (5 perhaps); it will return & ask you if you want all possible shell commands listed.

Option -e tells echo to interpret escape chatacters (such as \n, newline, \r, return, ... and yes, also \e). \e is the ESC (escape) character. echo does not seem to take it well if you put ESC before the end of the string argument (before the end of the string you want echo to print). It is basically the same if you interrupt a running echo command by hitting ESC manually.

Did you want echo to print exactly the string you gave it as an argument? In that case try to call echo without -e. Btw, there are a number of other commands that can lead to shell freezes and a still larger number that can lead to a lot more damage.


We are exactly the people our parents always warned us about.

Offline

#3 2014-06-18 17:38:12

lovetide
Member
From: China 中国
Registered: 2014-06-18
Posts: 2

Re: A single-line 'echo' command freezes vte-based terminal emulator

http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

ESC P    Device Control String ( DCS is 0x90).
...
ESC \    String Terminator ( ST is 0x9c).

...
Device-Control functions

DCS P s ; P s | P t ST    User-Defined Keys (DECUDK). 

Take a look at the Device-Control functions section of the page above.

The reason the terminal frozen is because the control sequence is not yet finished (in fact you only need echo -e '\eP' to "freeze" the terminal), and is waiting for ST to finish this control sequence.
So to finish the control sequence, hence unlock the terminal, you just need input the ST sequence which is '\e\' (type echo -e '\e\' blindly)

Last edited by lovetide (2014-06-18 17:46:17)


Hi, 你好

Offline

Board footer

Powered by FluxBB