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

Re: [BUG] Weird _expand & _complete behavior for $parameters in "double quotes"



On Tue, May 11, 2021 at 10:32 AM Marlon Richert
<marlon.richert@xxxxxxxxx> wrote:
>
> On Tue, May 11, 2021 at 2:05 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > I can't reproduce this on either Ubutu or MacOS, nor either with or
> > without my completeinword patch from the other day.
>
> Here's the test as a patch, in case it helps you reproduce it.

Ah, I didn't get before that you'd added an entire new test case.

There are two things going on here:

One, complete-in-word handling of quotes has several problems, which
I've unsuccessfully wrestled with once or twice before.  Completion
wants to remove the quotes, complete what is inside them, and then put
back the most appropriate quotes for the end result, which aren't
always the same as the original quotes ... and it can get pretty
confused along the way.  So the first TAB replaces "$ba" with "$ba""
because it recognizes the ambiguous prefix but forgets (so to speak)
that there's already a trailing quote.

Two, on the next tab when _expand sees the extra quote, it concludes
that $ba is the entire variable to be expanded, and replaces it with
the empty string.  The quotes then all themselves get quoted (see "put
back the most appropriate"+"confused"), leaving \"\"\".

This may be in some way related to the do_ambiguous() discussion from
workers/39123 all the way back in 2016, which never got any further
(and the patch from workers/39968 never did get committed, but it
doesn't help with this quoting situation).




Messages sorted by: Reverse Date, Date, Thread, Author