Cedric Martin
Cedric Martin

Reputation: 6014

How to get rlwrap to work inside Emacs' shell / eshell?

When I try to get rlwrap to work inside an Emacs (version 24.3.50.1) shell buffer (either M-x shell or M-x eshell), I get this error message:

rlwrap: Oops, crashed (caught SIGFPE) - this should not have happened!

For example:

 rlwrap telnet google.com 80

wors fine from a regular terminal (like xterm), but crashes from a shell inside an Emacs buffer.

Several people are having similar issue but the only "answer" I could find so far is a "RTFM" style answer on mailing lists. I did read that part of Emacs' doc and I don't understand what I'm supposed to do to make rlwrap work from within Emacs.

Upvotes: 5

Views: 884

Answers (2)

Vlatko Šurlan
Vlatko Šurlan

Reputation: 454

Actually you should use ansi-term or vterm with:

env -u INSIDE_EMACS rlwrap

The reason is that rlwrap assumes that we are in an environment which does not have terminal capabilities when it sees the INSIDE_EMACS environment variable. Of course, once you run a terminal emulator inside emacs this is no longer true, so we have to help rlwrap to be a bit less smart about it. Thus the env -u INSIDE_EMACS, which essentially translates to "No, we actually do have terminal capabilities so, pretty please rlwrap, do all your lovely terminal stuff!"

You can quickly confirm this for yourself by searching for INSIDE_EMACS in the rlwrap source code.

UPDATE: this bug in rlwrap has been fixed. If you're running into this your rlwrap is outdated.

Upvotes: 2

ale
ale

Reputation: 994

Try using M-xansi-term instead of shell/eshell.

shell and eshell do not provide terminal emulation functionality, but readline requires terminal emulation capabilities to move the cursor etc.

EDIT: using ansi-term is not enough, as explained in the answer below.

Upvotes: 6

Related Questions