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: Tue, 9 Feb 2016 07:50:50 -0800 [thread overview]
Message-ID: <160209075050.ZM30873@torch.brasslantern.com> (raw)
In-Reply-To: <20160209085356.5d9b7401@pwslap01u.europe.root.pri>
On Feb 9, 8:53am, Peter Stephenson wrote:
} Subject: Re: unset "hash[key]" isn't matched with what "key" may be
}
} All that occurred to me was an additional option to provoke an extra
} expansion step on the argument after locating the brackets.
}
} unset -? 'hash[$i]'
}
} would then be reliable. If the extra backslash stripping occurred early
} enough it wouldn't get in the way.
So what magic makes this work for typeset?
torch% typeset -A foo
torch% x='['
torch% typeset "foo[$x]"
zsh: not an identifier: foo[[]
torch% typeset 'foo[$x]' <-- note here
torch% typeset -p foo
typeset -A foo=( '[' '' )
torch%
Or perhaps an equally interesting question is, is that behavior in fact
incorrect and typeset shouldn't do it either?
Ksh:
$ x='['
$ typeset -A foo
$ typeset "foo[$x]"
ksh: typeset: foo[[]: invalid variable name
$ typeset foo[$x] <-- not an error?
$ typeset -p foo
typeset -A foo=(['[]']=) <-- but weird
$ typeset 'foo[$x]'
$ typeset -p foo
typeset -A foo=(['$x']= ['[]']=) <-- no expansion
$
next prev parent reply other threads:[~2016-02-09 15:50 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
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 [this message]
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=160209075050.ZM30873@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).