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

[PATCH] comparguments: treat empty description as if missing



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