[net.bugs.4bsd] 4.[123]bsd csh script handling bug

ado@elsie.UUCP (Arthur David Olson) (03/31/86)

Index:	bin/csh/sh.err.c

Description:
	csh mishandles "Command not found" errors in scripts.

Repeat-By:
	Typing the command
    repeat 25 echo oops 6789012345678901234567890123456789012345678901 > file
	and then either
		csh file
	or
		cat file | csh
	and noting the output:
		oops: Command not found.
		789012345678901: Command not found.
	where "780912345678901" turns out to be what's stored in "file"
	starting at the 1025th byte.

Fix:
	Move a misplaced "btoeof" call in "sh.err.c", as shown below.
	(Well. . .actually you'll want to wait and watch the next couple
	of weeks worth of followup postings before doing so.  And even then,
	you'll want to be sure that you can readily back out the change.)
	Changes are conditioned on OLDVERSION; these changes are for the 4.1bsd
	version of the code.

		...
		errspl = 0;

	#ifdef OLDVERSION
		/*
		 * Reset the state of the input.
		 * This buffered seek to end of file will also
		 * clear the while/foreach stack.
		 */
		btoeof();
	#endif /* OLDVERSION */

		/*
		 * Go away if -e or we are a child shell
		 */
		if (exiterr || child)
			exit(1);
	#ifndef OLDVERSION
		btoeof();
	#endif /* !OLDVERSION */

		setq("status", onev, &shvhed);
		...
--
Bugs is a Warner Brothers trademark.
Bug is a Volkswagen trademark.
--
	UUCP: ..decvax!seismo!elsie!ado		ARPA: elsie!ado@seismo.ARPA
	DEC, VAX, Elsie & Ado are Digital, Borden & Shakespeare trademarks.