Is this a bug? SunOS 4.1.1 csh, which, and $?prompt

Jonathan I. Kamens jik at athena.mit.edu
Mon May 6 08:28:22 AEST 1991


The "which" command needs to execute your .cshrc, in order to get its
hands on aliases and such, so it can tell you when it is aliased to
something.

Furthermore, it needs to execute the .cshrc with $prompt set, because
so many people put "if ($ $?prompt) exit" at the top of their .cshrc
file.

Most shell scripts don't have to pretend they're interactive.  "Which"
is a special case, and therefore has special problems :-).

How to solve it?  Well, one thing that comes to mind is not to put
stty commands in your .cshrc file.  They should be in your .login file
instead.  If that's not possible, then set a variable such as STTY_SET
after the first time you run stty, and then check if that variable is
set in .cshrc before doing it.  Something like this:

	if ($?prompt && (! $?STTY_SET)) then
		stty tostop erase ^H kill ^U
		setenv STTY_SET
	endif

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.shell mailing list