From: Bart Schaefer <schaefer@brasslantern.com>
To: Stephane Chazelas <stephane.chazelas@gmail.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: issues with ${array[x][y]}
Date: Tue, 6 Mar 2018 09:02:31 -0800 [thread overview]
Message-ID: <180306090231.ZM28167@torch.brasslantern.com> (raw)
In-Reply-To: <20180306151644.GA10296@chaz.gmail.com>
On Mar 6, 3:16pm, Stephane Chazelas wrote:
} Subject: issues with ${array[x][y]}
}
} $ a=(foo bar)
} $ x='a[1][1]'
} $ echo ${(P)x}
} foo
This is happening because ${{(P)var}[1]} must treat ${(P)var} as an array
any time the name referred to by $var is an array, so array-ness is being
preserved when doing the first a[1] dereference.
} 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
Having ${array[1][1]} is mostly for convenience, because it dates from
before ${${array[1]}[1]} would have been syntactically valid. It was
never intended to work as an assignment.
next prev parent reply other threads:[~2018-03-06 17:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 15:16 Stephane Chazelas
2018-03-06 17:02 ` Bart Schaefer [this message]
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=180306090231.ZM28167@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=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).