zsh-workers
 help / color / mirror / code / Atom feed
* issues with ${array[x][y]}
@ 2018-03-06 15:16 Stephane Chazelas
  2018-03-06 17:02 ` Bart Schaefer
  2018-03-08 19:11 ` Stephane Chazelas
  0 siblings, 2 replies; 4+ messages in thread
From: Stephane Chazelas @ 2018-03-06 15:16 UTC (permalink / raw)
  To: Zsh hackers list

$ 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-08 19:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 15:16 issues with ${array[x][y]} Stephane Chazelas
2018-03-06 17:02 ` Bart Schaefer
2018-03-06 21:16   ` Stephane Chazelas
2018-03-08 19:11 ` Stephane Chazelas

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).