csh problem involving nested ifs?

Bennett Todd bet at orion.mc.duke.edu
Tue Jul 18 05:50:58 AEST 1989


In article <3171 at quick.COM>, srg at quick (Spencer Garrett) writes:
>In article <5016 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes:
>
>-> generate_a_list_of_file_names |
>->   while read FNAME
>->   do
>->     do_something_with FNAME
>->   done
>-> 
>-> is second nature. And it's impossible in csh without massive inconvenience.
>-> By comparison, having TEST and EXPR builtin is a minor optimisation.
>
>What are you talking about?  It's easy and much more natural under csh.
>
>foreach fname (`generate_a_list_of_file_names`)
>	do_something_with_fname
>end

I am *so* glad bash is out; I used to use a C-shell for interactive work
just to get history and job control; I was always having to fire up
/bin/sh to do serious looping work. Here are some things csh croaks on:

	find ... -print | while read filename;do
		...
	done

If you try rewrite that as

	foreach f (`find ... -print`)
		...
	end

csh will bomb on command line too long.

	IFS=:
	while read login passwd uid gid gcos home shell;do
		# process /etc/passwd with fields broken down
	done </etc/passwd

I wouldn't know how to try that in csh -- without running a separate
invocation of sed(1) over /etc/passwd once per record.

	for f in ... # or while ...
		...
	done &

csh won't let me background an entire loop.

Basically, I get the impression that csh's attempts at programming
constructs are afterthoughts hacked in imperfectly, rather than properly
parsed grammar constructs.

-Bennett
bet at orion.mc.duke.edu



More information about the Comp.unix.wizards mailing list