From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: "ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Subject: ${(A)=xxx} - second go - now real bug.
Date: Wed, 7 Jul 1999 19:32:42 +0400 [thread overview]
Message-ID: <002501bec88d$f467f470$21c9ca95@mow.siemens.ru> (raw)
Reading docs once more I noted this:
A
Create an array parameter with ${...=...}, ${...:=...} or
${...::=...}. If this flag is repeated (as in AA), create an
associative array parameter. Assignment is made before sorting or
padding. The NAME part may be a subscripted range for ordinary
arrays; the WORD part *must* be converted to an array, for example
by using ${(AA)=...} to activate word splitting, when creating an
associative array.
Please, note the last sentence. It implies, that in case of array/hash
assignment the word is treated as in array assignment - that is, ${(A)foo=bar
baz} is basically the same as foo=(bar baz). At least, I find this natural and
useful. And I have a feeling, that it was once so. Currently we have:
bor@itsrm2:~%> : ${(AA)foo::=bar baz}
zsh: bad set of key/value pairs for associative array
bor@itsrm2:~%> print -l $foo
bor@itsrm2:~%> print ${(t)foo}
association
bor@itsrm2:~%> unset foo
bor@itsrm2:~%> : ${(A)foo::=bar baz}
bor@itsrm2:~%> print -l $foo
bar baz
bor@itsrm2:~%> print ${(t)foo}
array
I suggest changing it to the described. That is,
${foo=bar} - the same as foo=bar (with blanks quoted, 'course)
${(A)foo=bar}, ${(AA)foo=bar} -
the same as foo=(bar)
A good question is, if we should do globbing in above cases. I dare to say, that
it may be useful ... following the usual rules. That is, no globbing in
${foo=bar} and normal globbing in ${(A)foo=bar}
Additional suggestion - what about iterpreting the (A) and (AA) flags in
${(A):-bar} ? The main reason is, currently it is always producing scalar; but
there are cases (mostly globbing) where I'd like to have array. Again, splitting
is _not_ the same. This would allow to use
${(A):-*.txt}
to get a list of files instead of current
${(f)"$(print -l *.txt)"}
that always has a problem with new lines in file names. And it is more simple
and arguably faster.
And final question: how should the following (from parameter expansion) be
interpreted:
s:STRING:
Force field splitting (see the option SH_WORD_SPLIT) at the
separator STRING. Splitting only occurs in places where an array
value is valid.
I mean the last sentence?
regards
/andrej
next reply other threads:[~1999-07-07 15:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-07 15:32 Andrej Borsenkow [this message]
1999-07-07 15:43 ` Peter Stephenson
1999-07-07 15:50 ` Andrej Borsenkow
1999-07-07 17:42 ` Bart Schaefer
1999-07-07 17:15 ` Bart Schaefer
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='002501bec88d$f467f470$21c9ca95@mow.siemens.ru' \
--to=andrej.borsenkow@mow.siemens.ru \
--cc=zsh-workers@sunsite.auc.dk \
/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).