Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] comparguments: treat empty description as if missing
- X-seq: zsh-workers 54831
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] comparguments: treat empty description as if missing
- Date: Sun, 21 Jun 2026 02:38:38 +0000
- Archived-at: <https://zsh.org/workers/54831>
- Feedback-id: i9be146f9:Fastmail
- List-id: <zsh-workers.zsh.org>
comparguments treats the specs '-a' and '-a[]' differently -- the latter
gets formatted like it has a description, but ofc it's empty
it's kind of trivial, but i think it would be nice to treat them both as
having no description, if only because it makes it easier to generate or
massage lists of specs when they have a more regular structure. i don't
think there's any utility to the current behaviour, in any case
dana
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index e4edb9631..75f01521e 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -1470,8 +1470,11 @@ parse_cadef(char *nam, char **args)
freecadef(all);
zwarnnam(nam, "invalid option definition: %s", *args);
return NULL;
}
+ // treat empty description as if missing
+ if (p == descr)
+ descr = NULL;
*p++ = '\0';
c = *p;
} else
descr = NULL;
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index f58fa4123..b118f2626 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -823,6 +823,14 @@ F:shouldn't offer -t in the first case (with stacked options)
>line: {tst -x}{}
>DESCRIPTION:{%2Fxargdesc%f}
+ tst_arguments : -x '-y[]'
+ comptest $'tst -\t'
+0:empty description
+>line: {tst -}{}
+>DESCRIPTION:{option}
+>NO:{-x}
+>NO:{-y}
+
%clean
zmodload -ui zsh/zpty
Messages sorted by:
Reverse Date,
Date,
Thread,
Author