Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how to force scalar to be an array?
- X-seq: zsh-users 7946
- From: Andy Spiegl <zsh.Andy@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: how to force scalar to be an array?
- Date: Mon, 30 Aug 2004 18:39:25 +0200
- In-reply-to: <Pine.LNX.4.61.0408280806540.10647@xxxxxxxxxxxxxxxxxx>
- Kinfo: virscan ok
- Kinfo: NoRelay, NoSpam
- Kreccount: 1
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040827154905.GA26846@xxxxxxxxx> <Pine.LNX.4.61.0408271416370.4189@xxxxxxxxxxxxxxxxxx> <20040828074355.GA4953@xxxxxxxxx> <Pine.LNX.4.61.0408280806540.10647@xxxxxxxxxxxxxxxxxx>
Hi Bart,
> What I meant was:
>
> words=( $=result )
> print $words[1]
Ah! Thanks so much once again for your help.
> You can even do it in one expression:
>
> print ${${(A)=words::=$result}[1]}
Cool. But hard to read.
> You'd also think that the (@) flag would fix that, but it only
> *preserves* array-ness in the transition from inner to outer nested
> expansions, it doesn't *create* array-ness from a scalar.
Yep, I did think that. So maybe your suggestion below would be worth
discussion on zsh-workers. :-)
> The latter might be something we could consider changing without much risk
> of breaking anything.
> You can do that latter one in zsh, too, if you have extendedglob set:
>
> : ${result//(#b)([^[:space:]]#)(*)/}
> print -l $match[1] $match[2]
Uffda, gotta go back and read more of the zsh manual.
Thanks again, I really appreciate your help!
Andy.
--
o _ _ _
------- __o __o /\_ _ \\o (_)\__/o (_) -o)
----- _`\<,_ _`\<,_ _>(_) (_)/<_ \_| \ _|/' \/ /\\
---- (_)/ (_) (_)/ (_) (_) (_) (_) (_)' _\o_ _\_v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Life is like a box of chocolates.
You never know what you get. (Forrest Gump, 1994)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author