[comp.emacs] CMU process modes addenda 2.01c

shivers@A.GP.CS.CMU.EDU (Olin Shivers) (10/24/90)

Cmushell.el users sometimes get extra echoing of their input,
or echoed ^M's at the end of every line output by the subprocess:
    % cd ~
    cd ~^M
    % ls
    ls^M
    ascii.mc      jarsm         new.mips      restaur       tera^M
    barbox        lalr&rex      opinion.note  rmail1        vc^M
    bin           mcvl          parlisp       rpaper        wall^M
    % 

This will often happen, for example, when you are telnetting to
some machine from cmushell mode. The reason it happens is because of
the terminal modes the tty driver is running in, which cause
the echoing and ^M's.

All you have to do is make sure that your tty is in the correct
mode. The pty/tty that emacs gives you when you run a subprocess
usually has the right modes (no echo, no ^M), but if you
subsequently telnet to another machine, the pty/tty *it* uses
will oftentimes not have the right modes. You use the stty
program to check and set the tty modes. For general information
about stty, see the man page entry. However, the following
command will generally do the trick:
    stty -echo nl
The -echo flag says "no echo," and the nl flag says "echo newlines
just as newlines; don't add an extra carriage-return."

A complication to this simple fix is that some fancy shells --
like the CMU shell cmucsh -- insist on placing the terminal into
funny modes that you cannot override with stty. They do this so
they can do their own interactive command line processing for
history editing and filename completion.  If this is the case
with your default shell, don't use it inside emacs. You don't
need the fancy features anyway, because the emacs cmushell mode
gives them to you anyway -- so you lose no functionality by
switching to /bin/csh.  You can arrange for emacs to run /bin/csh
instead of your default shell by saying
    (setq explicit-shell-file-name "/bin/csh")
in your .emacs file. If you happen to fire up one of these
fancy shells, you can usually replace it with /bin/csh by using
the exec command:
    % exec /bin/csh
after which you can successfully issue stty commands.  The FSF
shell, bash, does *not* have this problem -- it is well behaved
even though it provides fancy features. I have not tried tcsh or
ksh.

That's all there is to it.
    -Olin