Csh if statement missing endif bug

Kevin Thomas kjt at minnow.sp.unisys.com
Sat Jun 1 01:39:37 AEST 1991


A bug in the version of csh we are running recently reared its ugly head.

The problem occurs when a csh is started from an application such as vi, and
the .cshrc contains an if/then/endif mismatch.  Under these conditions the
csh process prints an error message when it detects the missing endif, but
it then rapidly grows in size.  The csh never runs the command as it was asked
to do, and is probably trapped in a recursive loop.  Killing the process allows
the application to continue.

The .csh contains lines like the following:

	if ($?prompt) then
		set ignoreeof
		...

The if/then should be terminated with an endif, but it is not.  When the
user logs in, the csh doesn't complain at all.  This is probably because the
if expression evaluates to true.

If the user enters vi and enters the command ":!ls" the csh prints an error
message about the missing endif, and then goes into the loop described above.
I suppose that vi is attempting something like:

	execlp("csh","csh","-c","ls",NULL);

Therefore, the if expression in the .cshrc evaluates to false.  Csh must be
trying to skip to the end of the if/then/endif statement, but goes insane.

Our computer is a Unisys 5000/80 running Unix System 5.3.  The OS release
number is 6.03.00.

I'd be interested to know how widespread is this problem.  If you'd like to
give the above example a try on your OS and mail me the results, I will
summarize for the net.

-- 
Kevin Thomas             kjt at minnow.sp.unisys.com
Unisys Corporation       ...!pyramid!pwcs!minnow!kjt



More information about the Comp.bugs.sys5 mailing list