Allen Brown wrote:

> Not correct.  "$@" is handled as a special case by the shell.  (True
> for bash and ksh.)  Each element on the command line becomes one
> element at the insertion point.

I wasn't going to go into this, because Mr. O probably doesn't care.
But since you and Peter brought it up...

"$@" (with the quotes) has been a valid way to pass "all arguments,
correctly quoted" to the shell since the early days of the Bourne
shell in the late 1970s.  The classic Bourne shell had a bug where, if
there were zero arguments, "$@" would insert one zero-length argument.
Newer shells have fixed that bug, and you're unlikely to run into the
bug today.  But the workaround, for the pedantic (or the old fart who
won't shut up (-: ) is ${1+"$@"}.  That means, "If the 1st argument is
defined, substitute in all the args, correctly quoted."

        wget --whatever ${1+"$@"}

If you want to iterate over the arguments in sh, use "for i" with no
"in ..." clause.  That bypasses quoting issues completely.

        for i
        do echo "argument is $i"
        done

> In general "$@" is the Right Way to write scripts.  In this case,
> it probably doesn't matter since I don't think blanks are legal in
> URLs.

wget will translate a space into %20.

> But it is better to maintain good programming habits, so that
> argues for using "$@" even where it is moot.

Seconded.

-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     [EMAIL PROTECTED]
_______________________________________________
EUGLUG mailing list
[EMAIL PROTECTED]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to