Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

issues with ${array[x][y]}



$ 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