Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: zsh crashed when completing with pattern
- X-seq: zsh-workers 54206
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Ma Rocket <ma2014119@xxxxxxxxxxx>
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: Bug: zsh crashed when completing with pattern
- Date: Sun, 22 Feb 2026 18:33:01 -0800
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=q/QIMXHCmAfuibayyhU+G7X37x0taKHEA9RhzxFDXjw=; fh=x5EnZZez+YJCQ90xiC3DhwiYypdmfDQsrH7ejY5iiqw=; b=CH60xGMd1UdJ4CkWjtcnF/WrMhrny2ttnYWVV+t4OIw9ekLWrs3gWMsDbKC4/Yde9w 5SwvSGA9t25Wm85LUh6BmwaxIdAYl93I1tWTHU2kBCMuYjW2gxvE90EsVUIRWH0idlcv nIGQ39ZSbdRUl5BCJ2ZgCPMaLU2ist0RFPPWkh8FHs6eJ+W8Xi/OSf5poJFAlUxAKWFE 1+LZlFXC2Nt3E5TpnKN3Qg9SJeWq93iaU85eg3ImOM31qftx3C3W0DDdNuXjFWV+gfVH Wr3z3gu3V1GARFiy8bPHYRWuzA4Ycq3NGdq7odD2V2phs5cISNfxUgBginqpPTSYL6Qv CEGQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1771813992; cv=none; d=google.com; s=arc-20240605; b=Ao2X0cCCiCh5LHn0pVDe4uYUSGXmuSNvD9NIRdIRxHE6dxsI2eldW9U1YJU8T24Cuk xDHOJJpFsau+h6y52SoK9ERmgMcPfMU6s2aQ5d+6xkOy0zey+Ds05uZ3BN7C4ylr9Z/c GTWZTH3OW7FiK16AmoP2AI31mgPkwvroCrG90TxFM/TZUYABmp/deyGtMaWJSJh/Jesb 3JViOyMAUZ6x3s4X6DyHNC4Qpi3lKCCuFoiiznMqAkoqoQGdNHmTYUr338v5QSSDnZ41 zPEt+55m6u7QukL6qCerBaIsvFSMkwIdntBPg7yXKUROg5k6BDEtSeMuNZb5jjU6dOjS +AUg==
- Archived-at: <https://zsh.org/workers/54206>
- In-reply-to: <SYAPR01MB2781D475F6BFF1638B4AE9C8EE76A@SYAPR01MB2781.ausprd01.prod.outlook.com>
- List-id: <zsh-workers.zsh.org>
- References: <SYAPR01MB2781D475F6BFF1638B4AE9C8EE76A@SYAPR01MB2781.ausprd01.prod.outlook.com>
On Sun, Feb 22, 2026 at 8:28 AM Ma Rocket <ma2014119@xxxxxxxxxxx> wrote:
>
> I was writing completion script when I found zsh would crash on my `_arguments` argument.
> Here is the problematic line:
>
> '(-l --highlight)'{-l,--highlight}'[Byte to highlight]:*[:number:]+:HIGHLIGHTS INT: '
>
> The minimum completion script to reproduce: (filename: _sss)
>
> #compdef sss
>
> _arguments '-x[test]:*[:number:]:X: '
> EOF
>
> When press tab after `-x`, zsh crashed. I can predict that the pattern is the root cause.
Not exactly. It's the parse of the _arguments argument that's at
fault. Patch below fixes the core dump, but your _arguments syntax is
wrong. The colons separate parts of the argument spec, so you need to
protect any that are part of the pattern. The doc says
Any literal colon in an OPTNAME, MESSAGE, or ACTION must be
preceded by a backslash, '\:'.
That should also mention PATTERN.
_arguments '-x[test]:*[\:number\:]:X: '
Also, do you perhaps mean [[\:digit\:]] ? In your original line
[:number:]+
matches any of :,n,u,m,b,e,r followed by + (the patterns here aren't
regular expressions).
Note, I'm not 100% sure that the patched test for endpat shouldn't be
(!endpat || pattry(endpat,line))
but it doesn't seem to make any difference. Anyone?
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index d9bf368d0..8e56f47a7 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -3865,8 +3865,8 @@ enditem()
)
enditem()
-Any literal colon in an var(optname), var(message), or var(action)
-must be preceded by a backslash, `tt(\:)'.
+Any literal colon in an var(optname), var(pattern), var(message), or
+var(action) must be preceded by a backslash, `tt(\:)'.
Each of the forms above may be preceded by a list in parentheses
of option names and argument numbers. If the given option is on
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 55b0a9b9f..ccf2053f2 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2115,7 +2115,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
if (state.def->type == CAA_REST || state.def->type == CAA_RARGS ||
state.def->type == CAA_RREST) {
- if (state.def->end && pattry(endpat, line)) {
+ if (state.def->end && endpat && pattry(endpat, line)) {
state.def = NULL;
state.curopt = NULL;
state.opt = state.arg = 1;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author