From: Phil Pennock <phil@athenaeum.demon.co.uk>
To: zsh-users@math.gatech.edu
Subject: Re: counting in "for" loops
Date: Fri, 4 Dec 1998 15:53:50 +0000 [thread overview]
Message-ID: <19981204155350.44301@athenaeum.demon.co.uk> (raw)
In-Reply-To: <19981203212653.56779@athenaeum.demon.co.uk>; from "Phil Pennock" on Thu 3 Dec 1998 (21:26 +0000)
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?
prev parent reply other threads:[~1998-12-04 18:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-02 16:00 Sven Guckes
1998-12-02 16:16 ` Thomas Koehler
1998-12-02 16:21 ` Peter Stephenson
1998-12-03 3:15 ` Updating documentation (Re: counting in "for" loops ) Timothy J Luoma
1998-12-02 16:50 ` counting in "for" loops Bruce Stephens
1998-12-03 4:22 ` Geoff Wing
1998-12-03 21:26 ` Phil Pennock
1998-12-03 21:27 ` Geoff Wing
1998-12-04 15:53 ` Phil Pennock [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19981204155350.44301@athenaeum.demon.co.uk \
--to=phil@athenaeum.demon.co.uk \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).