Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: converting parameter to words

On Oct 13, 10:48am, Jack McKinney wrote:
} for i
} do
}   temp="$temp -r $i"
} done
} command $temp
} From the man page, it sounds like ${^temp} or ${=temp} should
} work, but neither does.

${=temp} should have done it for you:

zagzig[562] x="foo -r bar -r baz"
zagzig[563] print -l ${=x}

However, it would do the wrong thing if any of the original arguments
contained whitespace.

On Oct 13,  6:16pm, Nemeth Ervin wrote:
} for i in ...
} do
}   temp=("$temp[@]" -r "$i")
} done
} command "$temp[@]"

This is the right idea.  Unless you have shwordsplit set (which you must
not, or you wouldn't have needed ${=temp} in the first place) you don't
even need the quotes that Nemeth used; and unless you have shortloops
turned off you can just write it like this:

    local temp i
    for i; temp=($temp -r $i)
    command $temp

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author