Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: issues with ${array[x][y]}
- X-seq: zsh-workers 42433
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: issues with ${array[x][y]}
- Date: Thu, 8 Mar 2018 19:11:28 +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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x6mqM5foPVkq3SJ2R0WBEKB/Q9RlBLpdmjyEQ5Yx0pE=; b=qPIVPj8CbBhFPeFfPyYHNMURtEN0f8qLonVaJXP5AdTJ0Ao1P5lnM8ieKsOM9s0jIk TPRxW8BxPY4RBxQFsshlkircLMXVJn7Q4MDsoS/hg+hIp5XePD26BdHRgWpQxcTKVVIp EG0PYdIiQTcxY5a2cDzfFaT+W7idAT3FmvRmgKy4bKvr5S/1BqWzWL+QWH8vJTKjDdpv OwJqu89OHwgR9tAGJP/Q+dtGoXUo6KOmXYGYF20/zfxvl+oom+ZFJg3TB1QADNIxKOsV xqiF0dE1zCu+/b1FC3BaYDmlfNlzXjoFfArBGIQVk9Qjmch0KkQJPslmdd9H1aZnYDRI 1izA==
- In-reply-to: <20180306151644.GA10296@chaz.gmail.com>
- 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
- References: <20180306151644.GA10296@chaz.gmail.com>
2018-03-06 15:16:44 +0000, Stephane Chazelas:
[...]
> 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]
[...]
Also:
$ a=(213 345)
$ echo $((a[1])) $((${a[1]}))
213 213
$ echo $((a[1][2]))
zsh: bad base syntax
$ echo $((${a[1][2]}))
1
For reference, in ksh93, ${a[1][2][3]} is used for its
multi-dimensional arrays, and
${a[1][2]}
$((a[1][2]))
a[1][2]=x
((a[1][2] = 3))
typeset -n b='a[1][2]'
are recognised consistently, but ${a[1][2]=x} is buggy:
$ ksh -c ': ${a[1][2]=x}; typeset -p a'
typeset -a a=([1]=([0]=) )
$ ksh -c 'a[1][2]=x; typeset -p a'
typeset -a a=([1]=([2]=x) )
(of course, it's more important for ksh93, as multi-dimensional
arrays would be less useful without, while zsh's a[1][2] setting
the second character of the first element of a is not going to
be often useful (except maybe for the $mapfile case mentioned
earlier))
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author