Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Array as parameter
- X-seq: zsh-workers 29887
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Subject: Re: Array as parameter
- Date: Wed, 2 Nov 2011 12:06:49 +0000
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1320235611; bh=E3g/Az6TH7jX3YP4z1hI41DAxEObYuHUcFuqZISRyio=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:Content-Transfer-Encoding:In-Reply-To:User-Agent; b=qqsKbduW7PhHM1+pg2RH8xsoMV4gbAJqJOkKIk4gnfoPcZiF67D5uENPryumL752gA7LDjIWgwgFOlBKbyI7VIn7IEcQDiQDLOyfd6DBhGam99XuMR5Xh4QhXFIsAVjSYHXCZq3V/jH940I+b3kkBlbMj6xAsZQAHmgjAXNHQ+8=
- In-reply-to: <CAHYJk3QK6UzAcsQBwoV2rMk9Kga063_pRx8gGXHAoMgie5+_sA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Mikael Magnusson <mikachu@xxxxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20111102033545.GI28043@solfire> <CAHSx_SsGPHWkGfspXKo39oZ6G3Rd+H-8_2PAuixHmW94d4VCEg__34702.1825182766$1320210589$gmane$org@mail.gmail.com> <slrnjb228m.67l.stephane.chazelas@spam.is.invalid> <CAHYJk3QK6UzAcsQBwoV2rMk9Kga063_pRx8gGXHAoMgie5+_sA@mail.gmail.com>
2011-11-02 11:14:38 +0100, Mikael Magnusson:
> On 2 November 2011 10:10, Stephane CHAZELAS <stephane_chazelas@xxxxxxxx> wrote:
> > 2011-11-1, 22:00(-07), Wayne Davison:
> >> However, if you need to be able to keep the array
> >> parameter separate from other parameters, you could instead refer to the
> >> variable whose name you passed in using ${(P)1} in your function in place
> >> of the $1.
> >
> > Except that it doesn't work for arrays. You'd need to use eval
> > here.
>
> (P) works perfectly fine with arrays.
[...]
Indeed, though it seems you have to write it as "${${(@P)1}[@]}", I'm not too sure why.
~/install/cvs/pixz$ zsh -c 'a=("" "a b" c d); b=a; print -l "${${(P)b}[@]}"'
a b c d
~/install/cvs/pixz$ zsh -c 'a=("" "a b" c d); b=a; print -l "${${(@P)b}[@]}"'
a b
c
d
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author