Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _arguments option exclusion from a normal argument
- X-seq: zsh-workers 41983
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: _arguments option exclusion from a normal argument
- Date: Fri, 03 Nov 2017 22:49:03 +0100
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1509745744; bh=Zd+jorOhmFusE4ZX9/V1c4FD5GplYARggqiUCRf+XhY=; h=From:To:Subject:Date:From:Subject; b=h6giPU0pKp5Xzkn6idjuxnhGEaQkLhVqsc0J2320AzXAwv6oMy6nq7KYWQ7ubcCzLgWXjlovQzrw7494y/CleVg+I+kn6Fe++OmxqEU9kvnd7uiXydLfbW+SkanV/W+6h7623n24gqMwy6yzD+Dxqm2Yp9c3DBqSJjgVNPG+TYeEbECW9r1I5GTMlTfSEdC0db/RKfPS0kDSMgolPBKXI945w6tCgCGB/g4iQd28p/IK4BDHHkgXBW5n/hj+VEYNgDCCF5qQQDSC86s90MgzwjtAXn8q3ZYEcoQz4IC7JFGO9ssqKuyxWOhHNQ+6XmLu6QGK4Nj8gi8mMrac5ELwmQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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