Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
issues with ${array[x][y]}
- X-seq: zsh-workers 42425
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: issues with ${array[x][y]}
- Date: Tue, 6 Mar 2018 15:16:44 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=p5eizUR3uMKDo52RLN+KugD681VJiv9ej2epP/dRGCk=; b=OWRB04X7UOL7XcegDCYR55guJm7CfN6KsfIOG5rc+EXfFDyBXfT9knAaEEeB5MOrzk Gt6BF0g78LYZaA6Zwwu7YTTGEiDExkhtrxPv5mKt0QsxbS896AMdohkfCY5qcQXA3qqc 0tXt9Xp9E2M0m8AmHR/e9ADfKIUpn4JSim73jJ/K9H6Xxtu31tf8g6vkpZYPz2mIbDE+ qkiBOnIEeRq8qhK8PSI8dT+PIfzoLLXYvx0IRKT3eEoZxxLvX5zbZNtVWu1n/OR5iPQ2 10OMhfQX2454mWpigbtqO9ZSO35daKsQxGEnGuoirFKeQEkvERXfFVCKKVWtd1SGaq9H 6VkQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
$ 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author