Bug in csh

Root Boy Jim rbj at uunet.UU.NET
Fri Apr 26 04:54:33 AEST 1991


In article <24610 at as0c.sei.cmu.edu> dvk at sei.cmu.edu (Daniel Klein) writes:
>
>Well, here's an interesting one! Try typing:
>
>% echo hello & while (1)
>? end
>
>The "echo hello" gets executed at each loop of the while.  A similar bug
>does not exist with foreach, though.

You should know better than to try this. Csh is intrinsicly broken.
Anyway, it's not a bug, it's a feature. It's documented:

	The foreach, switch, and while statements, as well as the
	if-then-else form of the if statement require that the major
	keywords appear in a single simple command on an input line
	as shown below.

Sun says it better:

	Each occurrence of a foreach, switch, while,  if...then  and
	else built-in must appear as the first word on its own input line.

BTW, don't try piping to them or I/O redirection either.

Another broken feature: for integer values of X & Y try:

	(repeat X repeat Y echo foo) | wc -l

What is printed is not X*Y, but rather X+Y-1.

No one cares enuf to fix csh.

-- 
		[rbj at uunet 1] stty sane
		unknown mode: sane



More information about the Comp.bugs.4bsd.ucb-fixes mailing list