Using Eshell and the SSH command, I've logged on to a remote server. After installing a few server packages I noticed this strange thing:

enter image description here

Why is this happening? What can I do to prevent it?


ESC 7 and ESC 8 are terminal escape sequences that save and restore the cursor position.

Eshell is a terminal emulator that only aims to run command line applications, not full-screen text mode applications. So it sets the TERM environment variable to dumb to indicate that it is a dumb terminal, i.e. a terminal that can only display text and move to the next line, and does not support any escape sequence to do things like moving the cursor. SSH propagates the value of TERM to the remote host.

So either you have a configuration somewhere that mangles the value of TERM or the application you're running assumes that every terminal supports ANSI escape sequences, which is almost but not quite the case. Given that the remote application here is dpkg and I can't reproduce the problem, I suspect the former.

Possible fixes and workarounds:

  • If you have a configuration file somewhere that sets TERM, don't do it. It's always set by the terminal emulator.
  • If you want terminal escape sequences to work, use a full-fledged terminal emulator such as M-x term, and not a shell command line like M-x eshell.
  • If an application assumes that every terminal is an ANSI terminal, try running … | cat or cat | … or cat | … | cat instead of just . Even such applications will usually assume that they aren't running on a terminal if they're supplying output to a pipe.

Eshell is not a terminal. It does not interpret any escape sequences. The program you are running is using escape sequences to control the position of the cursor, so that it can draw a fancy progress bar. All well-behaved programs will only do this if the value of the TERM variable indicates that it is supported; make sure that you aren't setting this variable to anything other than "dumb" while using Eshell.

If the program is not well-behaved and simply assumes that you're running it in a terminal without checking (or of it only does useful things when it is running in a terminal), then you should add it to Eshell's list of visual commands, which is stored in the variable eshell-visual-commands. Eshell will run a terminal emulator for you whenever you run the commands in that list. For more information, see Chapter 4 Input/Output of the Eshell manual. To open the manuals, type C-h i. To go directly to this chapter of this manual, type C-h i g (eshell)Input/Output RET.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.