zsh-workers
 help / color / mirror / code / Atom feed
* _history_complete_{newer,older} complains on «unmatched» in _all_labels if globbing
@ 2014-10-21 21:08 Vasiliy Ivanov
  2014-10-22  6:43 ` _history_complete_{newer,older} complains on "unmat ched" " Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Vasiliy Ivanov @ 2014-10-21 21:08 UTC (permalink / raw)
  To: zsh-workers; +Cc: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

% typeset -a somevariable
% somevariable=(1 2 3)

% somev<_history-complete-older>  (completed to somevariable, all ok)

% *mevar<_history-complete-older> (completed properly, 2 items suggested – 'somevariable=(' and
'somevariable', guessed because expand prefix suffix style)

but fires hundreds of messages:
_all_labels:39: closing brace expected
…
_all_labels:39: unmatched '
…
_all_labels:39: unmatched "

reproducible with any globbing syntax, zsh 5.0.7

- -- 
Regards,
  Vasiliy Ivanov <beelzebubbie.logs@gmail.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJURstPAAoJEAnDj7eK12hqkMYH/Ak6JxfME5/1vDzyiarhz+N7
cRmMsOM4O61Kjs6z2xoUHFt3K2uBI4rZPcJw/lp2d5bCGYxIpDe+KvXiy5FbsJXs
qeA1YYEA06K7nHIHOgqmJ8hXVM3HXe7vvDN5CSeZgfV1UyL+pgww3gqnkD9m4wzL
q+ornRSnTBBn377+HismjDOANkrQmyxRkbinKN3owF2NsB8+/k4m8fvFGB3tFUh8
eDBjHfX1LVNwiXRazJgnmJixCxmuNzlHi5CAmLv9IyToZpvFJB+zTLzqPANfFtJ5
FTZAYj3iAaJyzCEtVQObPqSc+qvQS/qnZ/qdbkhh9Bx76BbLxwza8DonOxFs6lc=
=Br5k
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: _history_complete_{newer,older} complains on "unmat ched" in _all_labels if globbing
  2014-10-21 21:08 _history_complete_{newer,older} complains on «unmatched» in _all_labels if globbing Vasiliy Ivanov
@ 2014-10-22  6:43 ` Bart Schaefer
  2014-10-22  8:53   ` Vasiliy Ivanov
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2014-10-22  6:43 UTC (permalink / raw)
  To: zsh-workers

On Oct 22,  3:08am, Vasiliy Ivanov wrote:
} 
} % typeset -a somevariable
} % somevariable=(1 2 3)
} 
} % *mevar<_history-complete-older> (completed properly, 2 items suggested - 'somevariable=(' and
} 'somevariable', guessed because expand prefix suffix style)
} 
} but fires hundreds of messages:
} _all_labels:39: closing brace expected
} ...
} _all_labels:39: unmatched '
} ...
} _all_labels:39: unmatched "
} 
} reproducible with any globbing syntax, zsh 5.0.7

There's something else about your configuration that you're not telling
us, because I can't get any completions at all for *mevar unless I
"setopt globcomplete", and I don't get any error messages even with
that set.

Line 39 of _all_labels is

    "${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0

which ends up substituting into something like

     +_all_labels:39> compadd -1 -V -default- -X '%SCompleting %Uhistory word%u%s' -Q -a 'historywords[beg,beg+slice]'
     +_all_labels:39> __ret=0 

(though in your case the assignment to __ret is likely not happening)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: _history_complete_{newer,older} complains on "unmat ched" in _all_labels if globbing
  2014-10-22  6:43 ` _history_complete_{newer,older} complains on "unmat ched" " Bart Schaefer
@ 2014-10-22  8:53   ` Vasiliy Ivanov
  2014-10-22 11:08     ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: Vasiliy Ivanov @ 2014-10-22  8:53 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/22/14 12:43, Bart Schaefer wrote:
> On Oct 22,  3:08am, Vasiliy Ivanov wrote: } } % typeset -a somevariable } % somevariable=(1 2
> 3) } } % *mevar<_history-complete-older> (completed properly, 2 items suggested -
> 'somevariable=(' and } 'somevariable', guessed because expand prefix suffix style) } } but
> fires hundreds of messages: } _all_labels:39: closing brace expected } ... } _all_labels:39:
> unmatched ' } ... } _all_labels:39: unmatched " } } reproducible with any globbing syntax, zsh
> 5.0.7
> 
> There's something else about your configuration that you're not telling us, because I can't get
> any completions at all for *mevar unless I "setopt globcomplete", and I don't get any error
> messages even with that set.
> 
> Line 39 of _all_labels is
> 
> "${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0
> 
> which ends up substituting into something like
> 
> +_all_labels:39> compadd -1 -V -default- -X '%SCompleting %Uhistory word%u%s' -Q -a
> 'historywords[beg,beg+slice]' +_all_labels:39> __ret=0
> 
> (though in your case the assignment to __ret is likely not happening)
> 

I was able to reproduce with zsh -f and minimal configuration:

% setopt globcomplete
% autoload -U compinit
% compinit

but *only* with my existing (2300+ records) history file; starting with empty one doesn't throw
these messages.
Line 39 in my case is «compadd -1 -V -default- -Q -a historywords[beg,beg+slice]»

How can I debug this further (which history records leads to «unmatched» messages)?
Any hints will be extremely helpful.
- -- 
Regards,
  Vasiliy Ivanov <beelzebubbie.logs@gmail.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUR3CRAAoJEAnDj7eK12hqi+AH/R6a8YpO846e1OHZYm8RRQhj
MLhfKHVbAlgpWNZsBfwhdPOKykVqdT6y5bfanLK/dz17RZ9QK9NCLCxgnsABhY05
k58F9zqCseoxvTVWTpdbLSDwgebojQHYqf8qQ0GgF5FyPl0pD5iTT5pePO/cfLg7
hqvyGdghA4Ky5E6NfaaGxlZmaZmOBDJ1altIYlMVN2tfJHs1VB5eUIzDcgaI+vkv
D9TwVdADNOu/slEXfGD9UVzbP3T9FMp1YmFt1AVO2WnPo5P2oHguXjfZaNqdcoe/
4AffM+i/RzrG0U7zjk56q2d1ezpu8RkndUSTFoC5JBhm/gd7K+CieVlhR8vSxKo=
=N7u2
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: _history_complete_{newer,older} complains on "unmat ched" in _all_labels if globbing
  2014-10-22  8:53   ` Vasiliy Ivanov
@ 2014-10-22 11:08     ` Daniel Shahaf
  2014-10-22 21:26       ` Vasiliy Ivanov
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Shahaf @ 2014-10-22 11:08 UTC (permalink / raw)
  To: Vasiliy Ivanov; +Cc: Bart Schaefer, zsh-workers

Vasiliy Ivanov wrote on Wed, Oct 22, 2014 at 14:53:37 +0600:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 10/22/14 12:43, Bart Schaefer wrote:
> > On Oct 22,  3:08am, Vasiliy Ivanov wrote: } } % typeset -a somevariable } % somevariable=(1 2
> > 3) } } % *mevar<_history-complete-older> (completed properly, 2 items suggested -
> > 'somevariable=(' and } 'somevariable', guessed because expand prefix suffix style) } } but
> > fires hundreds of messages: } _all_labels:39: closing brace expected } ... } _all_labels:39:
> > unmatched ' } ... } _all_labels:39: unmatched " } } reproducible with any globbing syntax, zsh
> > 5.0.7
> > 
> > There's something else about your configuration that you're not telling us, because I can't get
> > any completions at all for *mevar unless I "setopt globcomplete", and I don't get any error
> > messages even with that set.
> > 
> > Line 39 of _all_labels is
> > 
> > "${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0
> > 
> > which ends up substituting into something like
> > 
> > +_all_labels:39> compadd -1 -V -default- -X '%SCompleting %Uhistory word%u%s' -Q -a
> > 'historywords[beg,beg+slice]' +_all_labels:39> __ret=0
> > 
> > (though in your case the assignment to __ret is likely not happening)
> > 
> 
> I was able to reproduce with zsh -f and minimal configuration:
> 
> % setopt globcomplete
> % autoload -U compinit
> % compinit
> 
> but *only* with my existing (2300+ records) history file; starting with empty one doesn't throw
> these messages.
> Line 39 in my case is «compadd -1 -V -default- -Q -a historywords[beg,beg+slice]»
> 
> How can I debug this further (which history records leads to «unmatched» messages)?
> Any hints will be extremely helpful.

Have you tried a binary search?

That is: split the history file to two roughly equal parts and try each
one of them to see if it reproduces the error.  It is likely that
exactly one of the two halves will reproduce the error.  Repeat the
bifurcation process recursively within that half until you narrow the
problem to a single history entry.

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: _history_complete_{newer,older} complains on "unmat ched" in _all_labels if globbing
  2014-10-22 11:08     ` Daniel Shahaf
@ 2014-10-22 21:26       ` Vasiliy Ivanov
  2014-10-23  3:18         ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Vasiliy Ivanov @ 2014-10-22 21:26 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/22/14 17:08, Daniel Shahaf wrote:
> Vasiliy Ivanov wrote on Wed, Oct 22, 2014 at 14:53:37 +0600:
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>> 
>> On 10/22/14 12:43, Bart Schaefer wrote:
>>> On Oct 22,  3:08am, Vasiliy Ivanov wrote: } } % typeset -a somevariable } % somevariable=(1
>>> 2 3) } } % *mevar<_history-complete-older> (completed properly, 2 items suggested - 
>>> 'somevariable=(' and } 'somevariable', guessed because expand prefix suffix style) } } but 
>>> fires hundreds of messages: } _all_labels:39: closing brace expected } ... }
>>> _all_labels:39: unmatched ' } ... } _all_labels:39: unmatched " } } reproducible with any
>>> globbing syntax, zsh 5.0.7
>>> 
>>> There's something else about your configuration that you're not telling us, because I can't
>>> get any completions at all for *mevar unless I "setopt globcomplete", and I don't get any
>>> error messages even with that set.
>>> 
>>> Line 39 of _all_labels is
>>> 
>>> "${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0
>>> 
>>> which ends up substituting into something like
>>> 
>>> +_all_labels:39> compadd -1 -V -default- -X '%SCompleting %Uhistory word%u%s' -Q -a 
>>> 'historywords[beg,beg+slice]' +_all_labels:39> __ret=0
>>> 
>>> (though in your case the assignment to __ret is likely not happening)
>>> 
>> 
>> I was able to reproduce with zsh -f and minimal configuration:
>> 
>> % setopt globcomplete % autoload -U compinit % compinit
>> 
>> but *only* with my existing (2300+ records) history file; starting with empty one doesn't
>> throw these messages. Line 39 in my case is «compadd -1 -V -default- -Q -a
>> historywords[beg,beg+slice]»
>> 
>> How can I debug this further (which history records leads to «unmatched» messages)? Any hints
>> will be extremely helpful.
> 
> Have you tried a binary search?
> 
> That is: split the history file to two roughly equal parts and try each one of them to see if
> it reproduces the error.  It is likely that exactly one of the two halves will reproduce the
> error.  Repeat the bifurcation process recursively within that half until you narrow the 
> problem to a single history entry.
> 
> Cheers, Daniel
> 

Thanks for refreshing my knowlegde, but *manual* binary search.. so scary :)
Nevertheless, I reproduced this error from the scratch:

$ zsh -f
% export HISTSIZE=9000
% export HISTFILE=~/.test.history
% export SAVEHIST=$HISTSIZE
% setopt sharehistory
% setopt extendedhistory
% setopt globcomplete
% autoload -U compinit
% compinit
% a='1 2'
% ^D (seems history must be loaded from file to cause error)

$ zsh -f
% export HISTSIZE=9000
…
% compinit
% *olo<^[/>
_all_labels:39: unmatched '
_all_labels:39: unmatched '
% <completed>autoload

adding b="3 4" to history increases error count:
% *olo<^[/>
_all_labels:39: unmatched "
_all_labels:39: unmatched "
_all_labels:39: unmatched '
_all_labels:39: unmatched '
% <completed>autoload

- -- 
Regards,
  Vasiliy Ivanov <beelzebubbie.logs@gmail.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUSCEOAAoJEAnDj7eK12hqBGgH/0+s1uRhtr4mTGwWIWOnRaeS
4/0DUvFKGg03B3TjWE4cPlHDjo8bGCGP/M3xfqf8YtfUrP4yKsGFe4cqO3zBlUbK
sxupJHd5OWviJACeV38K7Vhreahvpl7ZwLwXfbdnpnCeaYgOsBSdlJoKtrqdH+O/
RsUZvr8EFrxoD/vQBe0Li1cTtulJCB0pByBzuGMfGEHm7ilmwxfRB3zQebQRT18k
xIF8JjAincfImOcuwM3e3VjX0eeUeW/LO8utx8Qxc78VluawLUdC3sTsiOjTAx44
YtgtI/HzhdblV3RAcWKcwFBrwykI3EjacCHtjloHvnGNsx97mxr5WLd4AQnBHgc=
=GU5c
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: _history_complete_{newer,older} complains on "unmat ched" in _all_labels if globbing
  2014-10-22 21:26       ` Vasiliy Ivanov
@ 2014-10-23  3:18         ` Bart Schaefer
  2014-10-24 20:47           ` Vasiliy Ivanov
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2014-10-23  3:18 UTC (permalink / raw)
  To: zsh-workers; +Cc: Vasiliy Ivanov

On Oct 23,  3:26am, Vasiliy Ivanov wrote:
} Subject: Re: _history_complete_{newer,older} complains on "unmat ched" in 
}
} % a='1 2'
} % ^D (seems history must be loaded from file to cause error)

As a workaround until the patch below makes it into release, it would
probably silence this "unmatched" (and possibly make your completions
more pleasing) if you "setopt HIST_LEX_WORDS" in your .zlogin file.
See the description of that option for details.

} $ zsh -f
} % export HISTSIZE=9000
} ...
} % compinit
} % *olo<^[/>
} _all_labels:39: unmatched '
} _all_labels:39: unmatched '

OK, this really isn't directly related to history completion, it's a
generic problem with compadd invoking the parser without first telling it
to be quiet.  With HIST_LEX_WORDS the string being parsed would already
be a fully-quoted expression and the error would not occur in history
word completion (but might occur under other circumstances).


diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 4cd3b9f..05ae43a 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1014,6 +1014,7 @@ comp_match(char *pfx, char *sfx, char *w, Patprog cp, Cline *clp, int qu,
 	   Brinfo *bpl, int bcp, Brinfo *bsl, int bcs, int *exact)
 {
     char *r = NULL;
+    int onoerrs = noerrs;
 
     if (cp) {
 	/* We have a globcomplete-like pattern, just use that. */
@@ -1033,12 +1034,14 @@ comp_match(char *pfx, char *sfx, char *w, Patprog cp, Cline *clp, int qu,
 	     */
 	    teststr = dupstring(r);
 	    tokenize(teststr);
+	    noerrs = 1;
 	    if (parse_subst_string(teststr))
 		teststr = r;
 	    else {
 		remnulargs(teststr);
 		untokenize(teststr);
 	    }
+	    noerrs = onoerrs;
 	} else
 	    teststr = r;
 	if (!pattry(cp, teststr))


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: _history_complete_{newer,older} complains on "unmat ched" in _all_labels if globbing
  2014-10-23  3:18         ` Bart Schaefer
@ 2014-10-24 20:47           ` Vasiliy Ivanov
  0 siblings, 0 replies; 7+ messages in thread
From: Vasiliy Ivanov @ 2014-10-24 20:47 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/23/14 09:18, Bart Schaefer wrote:
> On Oct 23,  3:26am, Vasiliy Ivanov wrote: } Subject: Re: _history_complete_{newer,older}
> complains on "unmat ched" in } } % a='1 2' } % ^D (seems history must be loaded from file to
> cause error)
> 
> As a workaround until the patch below makes it into release, it would probably silence this
> "unmatched" (and possibly make your completions more pleasing) if you "setopt HIST_LEX_WORDS"
> in your .zlogin file. See the description of that option for details.
> 
> } $ zsh -f } % export HISTSIZE=9000 } ... } % compinit } % *olo<^[/> } _all_labels:39:
> unmatched ' } _all_labels:39: unmatched '
> 
> OK, this really isn't directly related to history completion, it's a generic problem with
> compadd invoking the parser without first telling it to be quiet.  With HIST_LEX_WORDS the
> string being parsed would already be a fully-quoted expression and the error would not occur in
> history word completion (but might occur under other circumstances).
> 
> 
> diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 4cd3b9f..05ae43a 100644 ---
> a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -1014,6 +1014,7 @@ comp_match(char *pfx,
> char *sfx, char *w, Patprog cp, Cline *clp, int qu, Brinfo *bpl, int bcp, Brinfo *bsl, int bcs,
> int *exact) { char *r = NULL; +    int onoerrs = noerrs;
> 
> if (cp) { /* We have a globcomplete-like pattern, just use that. */ @@ -1033,12 +1034,14 @@
> comp_match(char *pfx, char *sfx, char *w, Patprog cp, Cline *clp, int qu, */ teststr =
> dupstring(r); tokenize(teststr); +	    noerrs = 1; if (parse_subst_string(teststr)) teststr =
> r; else { remnulargs(teststr); untokenize(teststr); } +	    noerrs = onoerrs; } else teststr =
> r; if (!pattry(cp, teststr))
> 

Thanks for the patch and good advice for everyday use (HIST_LEX_WORDS).

- -- 
Regards,
  Vasiliy Ivanov <beelzebubbie.logs@gmail.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUSrrFAAoJEAnDj7eK12hqOKsH/if5Qz6Km4aIdSrz98h4l2BK
CPNP1uHgUvv4fVWXI3EDQlFFx9fodyb6aSij3sUTg5p0/KyEAp82WPKdAKZCEtBd
4ipJS128QMz4GPBJjkFSHOTffPdqz9ZhK9ganS6/YwRkMz1eQalfIriBpJTbzCcH
f/pg5FoJScElxlmoksjnVOTNV1G8w8i2PKRvHHUX8npEL2OQLKOmQg7E92HdxvXF
IVF/5gu3hpb3Z2FMIoNudN52fn9u2AH3lCES0+k9FWoDzNt0gXpLNlBWz5hKMrn9
vgnFP2qQocIkxhw0ISDxI1awlzi6s3ZI4fn7BR1YGn0KWyK4fW4lakOB7YjZmHg=
=Oqc6
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-10-24 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-21 21:08 _history_complete_{newer,older} complains on «unmatched» in _all_labels if globbing Vasiliy Ivanov
2014-10-22  6:43 ` _history_complete_{newer,older} complains on "unmat ched" " Bart Schaefer
2014-10-22  8:53   ` Vasiliy Ivanov
2014-10-22 11:08     ` Daniel Shahaf
2014-10-22 21:26       ` Vasiliy Ivanov
2014-10-23  3:18         ` Bart Schaefer
2014-10-24 20:47           ` Vasiliy Ivanov

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