Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _subscript quotes too much



"Mikael Magnusson" wrote:
> On 09/04/2008, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > % zsh -f
> >  % autoload -U compinit; compinit
> >  % typeset -A foo
> >  % foo[bar]=baz
> >  % foo[*.txt]=blue
> >  % echo $foo[<tab><tab><tab>
> >  % echo $foo[\*.txt]
> >
> >  % echo $foo[*.txt]
> >  blue
> >
> >  I had a look at _subscript but it didn't mean much to me. I thought
> >  maybe there was a (q) too many but there are none at all.

As there are no special rules for subscripts once it gets to the adding
of completions (obviously the list is generated specially), they use the
normal rules that would apply for quoting command line arguments, which
quote globbing characters.

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.

> Also a bit weird,
> % foo[{]=bar
> zsh: no matches found: foo[{]=bar
> % foo[{a,b}]=bar

I would certainly expect you to need quoting here, and foo[\{]=bar does
work.  The fact you get away with it the second time is luck.  Note
that only single argument substitution happens in subscripts.

> % echo $foo[\{a,b\}] #produced by tab complete
> bar
> % echo $foo[\{a,b}]
> bar
> % echo $foo[{a,b}]
> bar

Same comment, essentially, reinforcing my notion that not handling
$foo[\*.txt] is a bug.

> % echo $foo['{a,b}']

This is a side-effect of the fact that we're only doing single argument
substitution and not full argument parsing.  The quotes don't get parsed
as quotes.

> I guess I'm wandering into the land of very subtle rules here... :)

Oh, yes.

-- 
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