zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: unset "hash[key]" isn't matched with what "key" may be
Date: Sun, 7 Feb 2016 19:24:22 +0000	[thread overview]
Message-ID: <20160207192422.4e7e7684@ntlworld.com> (raw)
In-Reply-To: <CAKc7PVChWXnvN569t6fZbq34mDjAf_sYvuq_6aN2xBGyTzh+nA@mail.gmail.com>

On Sun, 7 Feb 2016 20:10:48 +0100
Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> I meant that "$i" iterates over keys of $functions

Ah, you mean

% i='opp+a[' 
% function 'opp+a[' { print Hi; }
% 'opp+a['
Hi
% unset "function[$i]"
unset: function[opp+a[]: invalid parameter name

That's because i is expanded first, so the brackets get confused.  So
you might expect

i='opp+a\['

to work to compensate, but it doesn't.  Nor does

unset 'function[$i]'

since there's no later expansion.

No, I can't see an obvious answer either, and it's not specific to
$functions, it happens with an ordinary hash.   It's not actually clear
to me what the right answer should be.  Somehow you need to make the
key stand out from the surrounding syntax.  Allowing backslash quoting,
which was the next guess, might be the asnswer, but see
http://xkcd.com/1638 for commentary on backslashes.

pws


  reply	other threads:[~2016-02-07 19:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-07 14:16 Sebastian Gniazdowski
2016-02-07 19:08 ` Peter Stephenson
2016-02-07 19:10   ` Sebastian Gniazdowski
2016-02-07 19:24     ` Peter Stephenson [this message]
2016-02-07 21:33 ` Bart Schaefer
2016-02-08  7:05   ` Bart Schaefer
2016-02-09  4:54     ` Bart Schaefer
2016-02-09  8:53       ` Peter Stephenson
2016-02-09 15:50         ` Bart Schaefer
2016-02-09 16:19           ` Peter Stephenson
2016-02-09 18:07             ` Bart Schaefer
2016-02-15  7:48   ` Sebastian Gniazdowski
2016-02-15 13:26     ` Nikolay Aleksandrovich Pavlov (ZyX)

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=20160207192422.4e7e7684@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).