Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: converting parameter to words
- X-seq: zsh-users 3454
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: "Jack McKinney" <jackmc-zsh-users@xxxxxxxxxxx>, zsh-users@xxxxxxxxxxxxxx
- Subject: Re: converting parameter to words
- Date: Fri, 13 Oct 2000 18:23:23 +0000
- In-reply-to: <20001013104819.A32478@xxxxxxxxxxxxxxxxxx>
- In-reply-to: <gmv3di04sz5.fsf@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <20001013104819.A32478@xxxxxxxxxxxxxxxxxx> <gmv3di04sz5.fsf@xxxxxxxxxxxxxxxxxxx>
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}
foo
-r
bar
-r
baz
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