From: Bart Schaefer <schaefer@brasslantern.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 13:33:07 -0800 [thread overview]
Message-ID: <160207133307.ZM31008@torch.brasslantern.com> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2016-02-07 21:33 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
2016-02-07 21:33 ` Bart Schaefer [this message]
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=160207133307.ZM31008@torch.brasslantern.com \
--to=schaefer@brasslantern.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).