csh programming problem

Maarten Litmaath maart at cs.vu.nl
Fri Mar 16 02:10:58 AEST 1990


In article <1990Mar15.102758.17051 at axion.bt.co.uk>,
	iwarner at axion.bt.co.uk (Ivan Warner) writes:
)In article <53408 at bbn.COM>, ellard at bbn.com (Dan Ellard) writes:
)> I am trying to write a shell script that takes several arguments and
)> passes them to child processes, i.e.
)> 
)> #!/bin/csh
)> foo $1 $2 ...
)> bar $1 $2 ...
)...
)> Unfortunately, this method does not work when $1 is something like 'a
)b', [...]
)...
)	what on earth is wrong with:
)
)#!/bin/csh 
)foo "$1" "$2"
)bar "$1" "$2"
)
)	have I missed some subtle point, or is this not a `wizards' question

You missed a subtle point: what if the number of arguments is unknown in
advance?  You can't say "$@" in csh.
Still this isn't a wizards question, because the answer can be found in the
csh manual:

	% set argv=('a b' \\c \') 
	% set argv=($argv:q pp)
	% cat aap 
	for i
	do
		echo "=$i="
	done
	% sh aap $*:q
	=a b=
	=\c=
	='=
	=pp=
	% 
--
 1) Will 4.5BSD have wait5()?         |Maarten Litmaath @ VU Amsterdam:
 2) Sleep(3) should be sleep(2) again.|maart at cs.vu.nl, uunet!mcsun!botter!maart



More information about the Comp.unix.wizards mailing list