[comp.emacs] Undesirable command line echoing in GNUmacs shells

agw@lexington.columbia.edu (Art Werschulz) (01/14/87)

Hello.

I've noticed that when running M-x shell under GNU Emacs, each command
line gets repeated, e.g.,

	% echo Hello
	echo Hello
	Hello
	% 

From the prompt, you can probably quess that the environment variable
SHELL has been set to /bin/csh.  

Now watch what happens when I change SHELL to be /bin/ksh.

	$ echo Hi
	Hi
	$ 

Voila!  The echoing of the command line disappears.

Plausible conclusion:  This has something to do with csh.

Additional clue:  When firing up a new shell (with SHELL set to be
/bin/ksh), I first get the message

	Switching to new tty driver...

at the top of the *shell* buffer.  Maybe this is of importance?

Questions:

(1.) Has anybody else noticed this?

(2.) Has anybody come up with a way of getting rid of this annoying
     behavior when /bin/csh is used?

Thanks.
	Art Werschulz

 	ARPAnet:  agw%lexington@columbia.edu
	USEnet:   ... {seismo, topaz}!columbia!lexington!agw
	BITnet:   columbia.edu!lexington!agw@wiscvm
	CCNET:    werschulz@CUCS20
	ATTnet:   Columbia University (212) 280-3610 280-2736
		  Fordham University  (212) 841-5323 841-5396

mly@PREP.AI.MIT.EDU (Richard Mlynarik) (01/15/87)

   Path: mit-eddie!rutgers!seismo!columbia!lexington.columbia.edu!agw
   From: agw@lexington.columbia.edu (Art Werschulz)
   Newsgroups: comp.emacs
   Date: 14 Jan 87 18:52:42 GMT
   Reply-To: agw@lexington.columbia.edu ()

   I've noticed that when running M-x shell under GNU Emacs, each command
   line gets repeated, e.g.,
You don't mention which version of emacs you are running, nor which
operating system/version you are running on.

	   % echo Hello
	   echo Hello
	   Hello
	   % 

   >From the prompt, you can probably quess that the environment variable
   SHELL has been set to /bin/csh.  

   Now watch what happens when I change SHELL to be /bin/ksh.

	   $ echo Hi
	   Hi
	   $ 

   Voila!  The echoing of the command line disappears.

   Plausible conclusion:  This has something to do with csh.

This is supposed to be a feature of the shell you are using -- it
notices that it is running under a pty and assumes that it should do
interactive stuff (usually, in effect, "stty -nl echo")

To turn it off, try doing "stty -echo" -- you could put this in your
~/.emacs_csh file to have this happen automatically.

pinkas@mipos3.UUCP (Israel Pinkas) (01/16/87)

>I've noticed that when running M-x shell under GNU Emacs, each command
>line gets repeated, e.g.,
>
>	% echo Hello
>	echo Hello
>	Hello
>	% 
>
>From the prompt, you can probably quess that the environment variable
>SHELL has been set to /bin/csh.  
>
>Now watch what happens when I change SHELL to be /bin/ksh.
>
>	$ echo Hi
>	Hi
>	$ 
>
>Voila!  The echoing of the command line disappears.
>
>Plausible conclusion:  This has something to do with csh.

I noticed that this happend to me as well.  I am using Gnu 17.64, under
Ultrix (version does not matter).  I traced the problem to running tset in
my .cshrc file.  Since prompt gets set when running csh under emacs, I had
to move tset to my .login.  (Checking whether prompt is set is the
recommended way for testing for interactive shells.)

The symptoms that I got were that all commands echoed, and that there was a
^M at the end of every line.  (Probably caused by the traslation to CR-LF.)

-Israel
-- 
----------------------------------------------------------------------
UUCP:	{amdcad,decwrl,hplabs,oliveb,pur-ee,qantel}!intelca!mipos3!pinkas
ARPA:	pinkas%mipos3.intel.com@relay.cs.net
CSNET:	pinkas%mipos3.intel.com

mayer@hplabsc.UUCP (Niels Mayer) (01/16/87)

An addendum for HPUX users:

The csh in HPUX has the additional "feature" that even if you do something
like "stty -echo" or "stty raw" in your .emacs_csh, it will insist on terminal
sanity. To turn this off, use /bin/csh -i -T. If this applies to you, check
out the following message I just sent to bug-gnu-emacs:

To: bug-gnu-emacs@mit-prep.arpa, mayer
Subject: fix for echo problem in csh shell buffer on HPUX
Date: Thu, 15 Jan 87 17:55:23 PST
From: Niels Mayer <mayer@hplnpm>

Those of you that use m-x shell with csh by setting 
explicit-shell-file-name to "/bin/csh" will have noticed problems with
echoing caused by the fact that HPUX's csh insists on remaining "sane"
despite all attepts at "stty raw -echo" and whatnot. Well here's a
sleazy fix that works by using and undocumented feature of HPUX's csh.

Replace the make-shell function with the following in shell.el and csh will
work correctly:

==============================================================================
(defun shell ()
  "Run an inferior shell, with I/O through buffer *csh*.
If buffer exists but shell process is not running, make new shell.
If a file ~/.emacs_csh exists, it is given as initial input
 (Note that this may lose due to a timing error if the shell
  discards input when it starts up.) --NPM -- it seems to work, though....
The buffer is put in shell-mode, giving commands for sending input
and controlling the subjobs of the shell.  See shell-mode.
See also variable shell-prompt-pattern.

Note that many people's .cshrc files unconditionally clear the prompt.
If yours does, you will probably want to change it.

This function was modified for hpux use. It assumes you want to use csh and
it makes csh work in 'insane' mode to prevent echoing of \n and input.
                                -- Niels P. Mayer (mayer@hplabs.hp.com)"
  (interactive)
  (switch-to-buffer (make-shell "csh" "/bin/csh"
				(if (file-exists-p "~/.emacs_csh")
				    "~/.emacs_csh")
				"-i -T")) ;;; -T = tenex mode ... prevents echo
  )
==============================================================================