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

PATCH: _arguments option exclusion from a normal argument



This is another follow-on bug fix to 40269 which was the patch that
dealt with exclusions of single letter options clumped in a single word.
That patch made more use of the cur parameter passed to ca_inactive.
However in this one particular call to ca_inactive, cur is effectively
wrong because argxor comes from an earlier loop iteration. That's
always been wrong but it didn't matter before. Subtracting 1 might not
strictly be accurate either but as exclusion lists apply to all
following words it does the job.

In practical terms this fixes a (-) exclusion on a normal argument to
also exclude long options. For completeness, I also added a + option to
the test case: (-) does exclude + options.

Oliver

diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 70cea9f27..71d61563b 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2080,7 +2080,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
         remnulargs(line);
         untokenize(line);
 
-	ca_inactive(d, argxor, cur, 0);
+	ca_inactive(d, argxor, cur - 1, 0);
 	if ((d->flags & CDF_SEP) && cur != compcurrent && !strcmp(line, "--")) {
 	    ca_inactive(d, NULL, cur, 1);
 	    continue;
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index 58a205112..3e974a5a6 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -499,12 +499,18 @@
 >NO:{-c}
 >NO:{-g}
 
- tst_arguments '(-)-h' -a -b -c
+ tst_arguments '(-)-h' -a -b -c --long +p
  comptest $'tst -h -\t'
 0:exclude all other options
 >line: {tst -h -}{}
 >MESSAGE:{no arguments}
 
+ tst_arguments --args -b -c +p '(-)1:normal'
+ comptest $'tst arg -\t'
+0:exclude all options from a normal argument
+>line: {tst arg -}{}
+>MESSAGE:{no more arguments}
+
  tst_arguments -a '(-a)-b'
  comptest $'tst - -b\C-b\C-b\C-b\t'
 0:exclusion only applies to later words



Messages sorted by: Reverse Date, Date, Thread, Author