Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _subscript quotes too much
- X-seq: zsh-workers 24803
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: _subscript quotes too much
- Date: Wed, 9 Apr 2008 12:00:25 +0100
- In-reply-to: <200804090849.m398n4W2012023@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <237967ef0804081708h72b87699n6235099044238a13@xxxxxxxxxxxxxx> <237967ef0804081711t6b4a9d88qa8b5367ba1ba8fb0@xxxxxxxxxxxxxx> <200804090849.m398n4W2012023@xxxxxxxxxxxxxx>
On Wed, 09 Apr 2008 09:49:04 +0100
Peter Stephenson <pws@xxxxxxx> wrote:
> > > % typeset -A foo
> > > % foo[*.txt]=blue
> > > % echo $foo[\*.txt]
> > >
> > > % echo $foo[*.txt]
> > > blue
>
> I've a vague feeling that not handling \* the same as * is a bug, but
> quoting in subscripts is a horrible can of worms. I would expect
> backslash-quoting, at least, to be uniformly applied.
Hmm... it isn't, and this appears to be deliberate at at least two points
in the code: lex.c:dquote_parse() (where we carefully choose when to make
backslashes active) and params.c:getarg() (where we put most of the active
backslashes back to real backslashes anyway). So we're actually going to
some lengths to make sure backslashes are *not* handled as quote characters
in subscripts but are retained. This is documented in Subscript Parsing in
the zshparam manual, in fact, where there's a long essay about why it's so
difficult. The paradigm is double quotes, where only some backslashed
characters are treated specially:
% print -r "\*"
\*
The usual workaround is to use a parameter.
As far as _subscript is concerned, it would have to be taught the rules for
which characters can be backslashed, this applied with ${...//.../...}, and
then the -Q flag passed to compadd. This shouldn't be too hard.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author