[comp.unix.questions] csh joke

maart@cs.vu.nl (Maarten Litmaath) (12/15/88)

mirk@warwick.UUCP (Mike Taylor) writes:
\	alias cart 'rn -c -s999 | awk \'{x+=$5}; END {print x}\''

\No deal.  I can't say exactly what is going wrong here, but for some reason,
\(Any of you Toreks/Spencers out there like to explain) csh(1) decides that
\quoting the inner 's with \ isn't good enough, and spits back a "Unmatched
\single quote" error at you.

Inside single quotes a backslash isn't treated specially, EXCEPT when followed
by your first `histchar', usually an exclamation mark; so csh breaks up the
command above as follows:

	alias	cart	'rn -c -s999 | awk \'{x+=$5}

	;	# this semicolon delimits the alias command!
	
	END {print x}\''

The next command is `END', followed by an argument with an escaped single
quote, and finally an UNMATCHED QUOTE!
And now for the joke:

	% alias	printf	'foreach i ( hello , world ! )\
	echo $i\
	end'
	% printf
	...

Better try it in a subshell...
-- 
fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
      let's go weepin' in the corner! |maart@cs.vu.nl, mcvax!botter!maart