Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: counting in "for" loops
- X-seq: zsh-users 1959
- From: Phil Pennock <phil@xxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: counting in "for" loops
- Date: Fri, 4 Dec 1998 15:53:50 +0000
- In-reply-to: <19981203212653.56779@xxxxxxxxxxxxxxxxxxxxx>; from "Phil Pennock" on Thu 3 Dec 1998 (21:26 +0000)
- Mail-followup-to: zsh-users@xxxxxxxxxxxxxxx
- Organisation: Organisation? Here? No, over there ---->
- References: <19981202170030.A2789@xxxxxxxxxxxxxxxxx> <slrn76c4h1.9s2.mason@xxxxxxxxxxxxxxxxxxxxx> <19981203212653.56779@xxxxxxxxxxxxxxxxxxxxx>
Typing away merrily, I produced the daft words:
> I wanted:
> % print ${(A)_::={1..10}}
> which would nicely leave $_ with the values, but _ is a readonly
> variable. *sigh*
The docs for [zshexpn(1)/PARAMETER EXPANSION/Parameter Expansion Flags]
state:
A Create an array parameter with ${...:=...} or ${...::=...}.
Assignment is made before sorting or padding.
However, this also works:
% print ${(A):-{1..10}}
since the null variable is unset. Undocumented feature?
Be careful not to use:
% print ${(A)-{1..10}}
though as this uses $- (shell flags) and seems to silently drop the (A)
and the {1..10} ... almost as if it parses - twice, once as a variable
and once as 'if not set' which is untrue.
Curious.
I'm also tempted to rewrite some of my initialisation files as:
: ${(A)path::=/bin /usr/bin /wherever/bin}
just to cheer myself up. *grin*
--
--> Phil Pennock ; GAT d- s+:+ a22 C++(++++) UL++++/I+++/S+++/H+ P++@ L+++
E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++ DI+ D+
G+ e+ h* r y?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author