Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!amgraf!cpsolv!rhg From: rhg@cpsolv.UUCP (Richard H. Gumpertz) Newsgroups: comp.unix.questions Subject: use of set in a shell script Message-ID: <472@cpsolv.UUCP> Date: 4 Jan 90 21:46:12 GMT Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz) Organization: Computer Problem Solving, Leawood, Kansas Lines: 39 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@CPS.COM | | Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 | ==========================================================================