Tested with 9e38ab81785c4ac755a7e78d2fe7a7db92bdf375:
comptesteval "typeset -a bar=({$'\\0'..$'\\C-?'})"
comptesteval 'typeset -A bat=( "$bar[@]" )'
comptesteval 'typeset bay="$bar"'
comptesteval 'unsetopt listambiguous'
comptest $': "$ba"\C-B\t\t'
0: complete parameter in double quotes
>line: {: "$ba}{"}
>DESCRIPTION:{parameter}
>NO:{bar}
>NO:{bat}
>NO:{bay}
>line: {: "$bar}{"}
% make TESTNUM=Y01 check
[...]
-line: {: "$ba}{"}
+line: {: "$ba}{""}
DESCRIPTION:{parameter}
NO:{bar}
NO:{bat}
NO:{bay}
-line: {: "$bar}{"}
+line: {: \"\"\"}{}
+DESCRIPTION:{expansions}
+NO:{\"\"\"}
+DESCRIPTION:{all expansions}
+NO:{\"\"\"}
+DESCRIPTION:{original}
+NO:{"$ba""}
Test ./Y01completion.ztst failed: output differs from expected as
shown above for:
comptesteval 'unsetopt listambiguous'
comptest $': "$ba"\C-B\t\t'
Was testing: complete parameter in double quotes
I can't reproduce this on either Ubutu or MacOS, nor either with or without my completeinword patch from the other day.
[-- Attachment #1: Type: text/plain, Size: 482 bytes --] On Tue, May 11, 2021 at 2:05 PM Bart Schaefer <schaefer@brasslantern.com> wrote: > > I can't reproduce this on either Ubutu or MacOS, nor either with or > without my completeinword patch from the other day. I tried it again, but this time as follows: make realclean Util/preconfig configure make all TESTNUM=Y01 check I still get the exact same test failure. macOS, commit 9e38ab81785c4ac755a7e78d2fe7a7db92bdf375. Here's the test as a patch, in case it helps you reproduce it. [-- Attachment #2: 0001-_expand-_complete-parameters-in-double-quotes.txt --] [-- Type: text/plain, Size: 1179 bytes --] From f5d77fe457da42de2bb23ba95476cc14466d19c0 Mon Sep 17 00:00:00 2001 From: Marlon Richert <marlon.richert@gmail.com> Date: Tue, 11 May 2021 20:27:50 +0300 Subject: [PATCH] _expand & _complete $parameters in "double quotes" --- Test/Y01completion.ztst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index 2c6d25d9a..8034f0c67 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -282,6 +282,19 @@ F:regression test workers/31611 >NO:{bar} >NO:{baz} + comptesteval "typeset -a bar=({$'\\0'..$'\\C-?'})" + comptesteval 'typeset -A bat=( "$bar[@]" )' + comptesteval 'typeset bay="$bar"' + comptesteval 'unsetopt listambiguous' + comptest $': "$ba"\C-B\t\t' +0: complete parameter in double quotes +>line: {: "$ba}{"} +>DESCRIPTION:{parameter} +>NO:{bar} +>NO:{bat} +>NO:{bay} +>line: {: "$bar}{"} + comptesteval '_tst() { local disp=( {a..z} ); compadd -ld disp $disp[@]; comppostfuncs=( _pst ) }' comptesteval '_pst() { local disp=( "<INSERT>$compstate[insert]</INSERT>" ); compadd -Qld disp $disp }' comptesteval "zstyle ':completion:*' menu select=long-list" -- 2.31.1
On Tue, May 11, 2021 at 10:32 AM Marlon Richert
<marlon.richert@gmail.com> wrote:
>
> On Tue, May 11, 2021 at 2:05 PM Bart Schaefer <schaefer@brasslantern.com> 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).
On Tue, May 11, 2021 at 10:40 PM Bart Schaefer <schaefer@brasslantern.com> wrote: > > On Tue, May 11, 2021 at 10:32 AM Marlon Richert > <marlon.richert@gmail.com> wrote: > > > > On Tue, May 11, 2021 at 2:05 PM Bart Schaefer <schaefer@brasslantern.com> 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. Sorry about the confusion. Yes, I added a new test case, because I saw this happen on the command line, but I wanted to make sure that A) it wasn't just my environment and B) I presented the bug in a way that you could easily reproduce it. Next time, I guess I'll just send it as a patch in the first place. :) > 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. Note that my test case does not set COMPLETE_IN_WORD and setting it doesn't appear to make any difference for this case.
On Tue, May 11, 2021, at 1:32 PM, Marlon Richert wrote:
> I tried it again, but this time as follows:
>
> make realclean
> Util/preconfig
> configure
> make all TESTNUM=Y01 check
>
> I still get the exact same test failure. macOS, commit
> 9e38ab81785c4ac755a7e78d2fe7a7db92bdf375.
>
> Here's the test as a patch, in case it helps you reproduce it.
>
> Attachments:
> * 0001-_expand-_complete-parameters-in-double-quotes.txt
Should this test case be committed?
--
vq
On Sun, May 23, 2021 at 2:04 PM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> On Tue, May 11, 2021, at 1:32 PM, Marlon Richert wrote:
> > * 0001-_expand-_complete-parameters-in-double-quotes.txt
>
> Should this test case be committed?
I would say "no". At best it would be an "xfail" test, but we don't
yet know if the eventual non-error output will match what Marlon
expected when he made up the test.
Bart Schaefer wrote on Mon, May 24, 2021 at 13:13:04 -0700: > On Sun, May 23, 2021 at 2:04 PM Lawrence Velázquez <larryv@zsh.org> wrote: > > > > On Tue, May 11, 2021, at 1:32 PM, Marlon Richert wrote: > > > * 0001-_expand-_complete-parameters-in-double-quotes.txt > > > > Should this test case be committed? > > I would say "no". At best it would be an "xfail" test, but we don't > yet know if the eventual non-error output will match what Marlon > expected when he made up the test. We could still do the following, though? Based on Marlon's patch, but with expectations adjusted. diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index 882a0adc4..f507996f1 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -322,6 +322,14 @@ F:regression test workers/31611 >NO:{y} >NO:{z} + comptesteval "typeset -a bar=({$'\\0'..$'\\C-?'})" + comptesteval 'typeset -A bat=( "$bar[@]" )' + comptesteval 'typeset bay="$bar"' + comptesteval 'unsetopt listambiguous' + comptest $': "$ba"\C-B\t\t' | fgrep line: | fgrep '\"\"\"' +-Df: complete parameter in double quotes +# When this test starts to pass, add proper expectations. + %clean