Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=GH96h3gcOoMGk/ACFhglN2CbjSnpYjZJ4e3i9u0s5f0=;
        b=UwmtZFPHIrp7pms030ZXW3WFfsteiUE46uskhF14TpnMLrdOrO0SOjaDWkvhWKG9Mv
         +4C5TkwzehJ4UaTvcCMasAhN334vDrES/2foMehQ1G4Qx0KNF+3qh+KwlQYo7TdfrBH9
         fO8x5ms5HDQUSxRkYI2190Cpax6VgMK+/4IwsXFkBAf0PMhrEJeoyoly19RsFjL/oCTO
         3u4mZc5GIOo95l0umpAXHOx9t62JZjuMUAH1DSO28yU4hlgNruzypYcCZAb68y8Nimvz
         Me32YMxRhBA1zFQjRciiecw0NFOvvhBdWAk9gJNAUdf9Nwc+lKlXYWCid4T47XGmn5CG
         e8DA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=GH96h3gcOoMGk/ACFhglN2CbjSnpYjZJ4e3i9u0s5f0=;
        b=U2YM+pT29fq9zMJz5xSSOuecGHI/t+S3NhHJ5arDFp3+Gad/9/gR9p8ZOZMGQ3Ss1K
         7lsqq9zZLquxsyCS+cTCyt0RW5W2Z4aGQXqpL9Js+u+tYfmV3dE5ZvebPdCxbMYO6saZ
         YLXGEQ6Iey8Qgnn5k+/H/7Afv0qIomKV9Xa2AH3z1PnlL6oleGQgvxafVlne8wcHA9fG
         15deFoTzoU5qZ81Id+PjHMYdQIg7sKS1nwL6jHXMdI6hNFoE5Mb9h0EqYaoDa6nv3MLT
         RCEKjYRDt7JqJv+sGJ65bQW/x554OnzbiWW3Xu1XhA5//eNya/xvT9J9dE9z1W6dOuN3
         ZujQ==
X-Gm-Message-State: AG10YORGPjh0PKcOk5WVBPmgiy6kHcCyU9wR5OIQ7uKGZMW1xhObCHtlR1NnUPJoRYGuZQ==
X-Received: by 10.66.235.36 with SMTP id uj4mr38083093pac.85.1454880782665;
        Sun, 07 Feb 2016 13:33:02 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160207133307.ZM31008@torch.brasslantern.com>
Date: Sun, 7 Feb 2016 13:33:07 -0800
In-Reply-To: <CAKc7PVBXd-UGwM+_tRSwuw-WL154YaTys6-t3iuzfAsG-RC-YQ@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "unset "hash[key]" isn't matched with what "key" may be" (Feb  7,  3:16pm)
References: <CAKc7PVBXd-UGwM+_tRSwuw-WL154YaTys6-t3iuzfAsG-RC-YQ@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: unset "hash[key]" isn't matched with what "key" may be
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37910

[I see PWS has already responded while I was trying to work out what the
code is doing.  Here's what I've written so far, maybe I can come up with
a patch in a bit longer.]

On Feb 7,  3:16pm, Sebastian Gniazdowski wrote:
}
} I was testing following plugin:
} 
} https://github.com/hchbaw/opp.zsh

Which incidentally says (README.md) it is obsolete for zsh >= 5.0.8.

} It creates functions with sophisticated names, like
} 
} opp+a(                               opp+a)
} opp+a<                               opp+a>
} opp+a[                               opp+a]

Ooh, interesting.  Making use of the side-effect that you can give a
ZLE widget a function name that can't normally be typed unquoted on a
command line.  Kinky.

}                 unset "func[$i]"
} 
} yielded:
} 
} -zplg-diff-functions:unset:36: func[opp+a\[]: invalid parameter name

Yep, "unset" is pretty naive about parsing the subscript there.  It wants
the square brackets in balanced pairs and doesn't consider any kind of
quoting.  (The -m option also doesn't work for subscripts.)

For whatever it's worth, this doesn't work in ksh either (at least as of

$ print $KSH_VERSION
Version JM 93u 2011-02-08

) although the error isn't printed in the exact same circumstances; in
some cases it just silently fails:

$ y='['
$ ary=([$y]=1)
$ typeset -p ary
typeset -A ary=(['[']=1)
$ unset ary[$y]
$ typeset -p ary
typeset -A ary=(['[']=1)
$ ary[x]=1
$ typeset -p ary
typeset -A ary=(['[']=1 [x]=1)
$ unset ary[x]
$ typeset -p ary
typeset -A ary=(['[']=1)
$ unset "ary['[']"   
ksh: unset: ary['[']: invalid variable name
$ unset ary[\[]
$ typeset -p ary
typeset -A ary=(['[']=1)
$ 


-- 
Barton E. Schaefer

