🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #100102

Re: shell buffers

#100102
From: David C Lawrence
Date: Mon, 06 Nov 1989 22:11
55 lines
3383 bytes
In <8911061614.AA01724@august> pgs@AI.MIT.EDU (Patrick Sobalvarro) writes:
Patrick> These days, whenever I use a shell buffer in Emacs on any of
Patrick> the AI Lab Suns, I get each of my input lines echoed with a
Patrick> ^M following, and all output also has a ^M following.

This is because your shell is generating them.

Patrick> This is really irritating when one is trying to use LISP in a shell
Patrick> buffer, as paren-hacking on multi-line input doesn't work.

Agreed; it can be annoying.  Finger output has the same problem.

Patrick> I believe that this appeared sometime around the time of the
Patrick> switchover to SunOS4.0, although I'm not absolutely sure.

Was that around the time that you changed to using tcsh for your
shell?  The Emacs shell package looks for explicit-shell-file-name
first, then in your environment for ESHELL, followed by SHELL and
finally it defaults to /bin/sh if none of the previous variables were
non-nil.  For flashy shells like tcsh, ecsh and bash, the terminal is
controlled so that the flashiness is possible at all.  bash is
actually very good about these things -- the only time I've seen it
muck with putting a ^M in is with the newline in my PS1.

How the shell is handling its terminal, though, is what causes the
problem.  It's not the OS and it's not Emacs; that is, they're not
doing anything they haven't been doing all along.  What happens on
input is that (in your case) tcsh doesn't have any idea what you've
typed until you press enter.  It then gets fed to the shell by Emacs
and it is processed one character at a time as they are received.
When tcsh sees them it figures it should show them to the typist,
which is a good assumption when connected directly to the terminal
without an interferring interpreter like Emacs.

On output, tcsh output CR-LF pairs because some hardware needs it for
correct cursor positioning -- the LF alone would not put the cursor
back in column zero.  Normally CR-LF interpretation is handled by the
terminal driver, but in this case Emacs is substituting for that
position and ^M needs a different representation to be distinguished
from ^J.  Some shells, like ecsh, will let you stty -ocrnl and the
results will be mostly usable.  tcsh however does "terminal mode
sanity-checking" and will override that setting by the time the next
command is sent.

The net result of all of this is to set either explicit-shell-file-name
or ESHELL so Emacs will never get as far as checking SHELL.  Neither
sh nor csh exhibit the problems described here and the only trouble
I've seen from bash is the one described with PS1.

Dave

[For more information on terminal control, see "termio" in section 4
of the manual.]
-- 
 (setq mail '("tale@pawl.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))
Technical Details
Message-ID: <1989Nov6.221118.730@rpi.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!rpi!tale
References: <8911061614.AA01724@august>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,d00038b8661e45a5
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1989-11-06 20:15:03 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!rpi!tale
From: tale@pawl.rpi.edu (David C Lawrence)
Newsgroups: gnu.emacs.bug
Subject: Re: shell buffers
Message-ID: <1989Nov6.221118.730@rpi.edu>
Date: 6 Nov 89 22:11:18 GMT
References: <8911061614.AA01724@august>
Organization: Rensselaer Polytechnic Institute, Troy NY
Lines: 55
Posted: Mon Nov  6 23:11:18 1989