Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unset "hash[key]" isn't matched with what "key" may be
- X-seq: zsh-workers 37910
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: unset "hash[key]" isn't matched with what "key" may be
- Date: Sun, 7 Feb 2016 13:33:07 -0800
- 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==
- In-reply-to: <CAKc7PVBXd-UGwM+_tRSwuw-WL154YaTys6-t3iuzfAsG-RC-YQ@mail.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>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBXd-UGwM+_tRSwuw-WL154YaTys6-t3iuzfAsG-RC-YQ@mail.gmail.com>
[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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author