On Mar  8, 2000, "Lars J. Aas" <[EMAIL PROTECTED]> wrote:

> On Wed, Mar 08, 2000 at 11:09:07AM +0100, Akim Demaille wrote:
> : | eval set $list
> : | for elt in "$@"; do
> : |   echo $elt
> : | done
> : | 
> : | So there.  Now you won't get any more suggestions from me :)
> : 
> : I agree, this is perfect.

> Actually, I was informed by John W. Eaton through private email that
> the 'in "$@"' part is the default and can therefore be dropped.

Yep, as long as you move the `do' to the next line.  Some shells can't
parse `for elt; do' :-(

> My opinion on this (which is influenced by my personal sh-scripting
> conventions) is that "for elt; do" is a bit less readable than the
> full thing.

ACtually, to be fully equivalent to `for elt \n do', you must write:
for elt in ${1+"$@"}; do

Some shells will expand "$@" to "" even if $# = 0.

But then, this doesn't apply here, since we know we've got at least
one argument.

-- 
Alexandre Oliva     http://www.ic.unicamp.br/~oliva/     Enjoy Guaranį
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

Reply via email to