use of set in a shell script

Maarten Litmaath maart at cs.vu.nl
Tue Jan 9 08:58:43 AEST 1990


In article <472 at cpsolv.UUCP> rhg at cpsolv.UUCP (Richard H. Gumpertz) writes:
\...	set $DIRS
\	find $@ -type f -exec ...
\
\...  Isn't the above
\roughly equivalent to (but slower than)
\	find $DIRS -type f -exec ...
\where the set command has been deleted?  The only difference I can see is that
\the version with the set command will make one more passing unquoting things,
\which could have been avoided using
\	set $DIRS
\	find "$@" -type f -exec ...

What will happen to an unquoted variable?
1)	It is broken up into words at sequences of IFS.
2)	It is globbed.
No unquoting.

\Are there any other subtle differences that I missed?  Is there any way to
\avoid the one pass of unquoting things that seems to remain in either case?

optc=0
optv=

for i
do
	case $i in
	-*)
		optc=`expr $optc + 1`
		eval optv$optc='"$i"'
		optv="$optv \"\$optv$optc\""
		;;
	*)
		# you get the idea
	esac
done

eval set $optv		# restore the options EXACTLY
-- 
1755 EST, Dec 14, 1992: Henry Spencer is put on a one-way mission to the moon.|
  Maarten Litmaath @ VU Amsterdam:  maart at cs.vu.nl,  uunet!mcsun!botter!maart



More information about the Comp.unix.questions mailing list