From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: issues with ${array[x][y]}
Date: Tue, 6 Mar 2018 15:16:44 +0000 [thread overview]
Message-ID: <20180306151644.GA10296@chaz.gmail.com> (raw)
$ a=(foo bar)
$ x='a[1][1]'
$ echo ${(P)x}
foo
$ echo ${a[1][1]}
f
There's also a consistency issue in that one can do:
string[1]=x
and reference ${array[1][1]}
but:
$ a[1][1]=b
zsh: no matches found: a[1][1]=b
$ ((a[1][1] = 2))
zsh: bad base syntax
$ typeset 'a[1][1]=2'
zsh: not an identifier: a[1][1]
See also:
$ a=(foo bar)
$ echo ${a[1][1]-a}
f
~$ echo ${a[1][1]::=a}
zsh: not an identifier: a[1][1]
$ echo ${a[1][1]:=a}
f
(see how it's happy about a[1][1] for dereferencing, but complains that it's not valid when assigning).
zsh 5.4.2 on Debian.
Same goes for associative arrays (I was initially checking
what would happen with mapfile[file][1,10]=text).
--
Stephane
next reply other threads:[~2018-03-06 15:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 15:16 Stephane Chazelas [this message]
2018-03-06 17:02 ` Bart Schaefer
2018-03-06 21:16 ` Stephane Chazelas
2018-03-08 19:11 ` Stephane Chazelas
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=20180306151644.GA10296@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=zsh-workers@zsh.org \
/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).