use of set in a shell script
Richard H. Gumpertz
rhg at cpsolv.UUCP
Fri Jan 5 08:46:12 AEST 1990
I recently came across a shell script that, among other things, did the
following:
OPTIONS=
DIRS=
for ARG
do
case "$ARG" in
-*) OPTIONS="$OPTIONS $ARG";;
*) DIRS="$DIRS $ARG";;
esac
done
if test -z "$DIRS"; then
DIRS="."
fi
set $DIRS
find $@ -type f -exec ...
where the "..." in the find command indicates irrelevant stuff that I have
omitted.
My question is, why do the set in the next to last line? 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 ...
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?
Is there a better way to write this whole thing? (No, perl is not an
acceptable alternative in this case; perl scripts will be read but will not
solve my problem.)
--
==========================================================================
| Richard H. Gumpertz (913) 642-1777 or (816) 891-3561 rhg at CPS.COM |
| Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 |
==========================================================================
More information about the Comp.unix.questions
mailing list