Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: some repeatable options in completions
- X-seq: zsh-workers 44791
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: "Zsh workers" <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: some repeatable options in completions
- Date: Sun, 29 Sep 2019 18:00:56 +0200
- 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=1569772859; bh=TrjTOyYKLGrqChV+N8RQEJPHIZMA/zNnk8A77/Wacdg=; h=From:References:To:Subject:Date:From:Subject; b=XaGcZgR6UHy/d0w0oSRx1piJfkZ3NbtzCkUh7uJfJVK31W92bQyYfndWHaXWC5wh9ld299f4mT8GQsJ7dzT3JHGzUDwtdoAQgU8fz0vGsnuTL5dhdAMKHU894SrNTv/GldTJWb9uKb8hQ/6Qb5fDx1M59neZaakSE2MiyIGnU5gbGnMXFqk7vrror/5xq7h4I13hw01s7aMK6pCuIqJpkB4n3QcvbGxEaxSwf/AgcC2pTCk2AE2BuKukI5UIV9Qzsfmjqm2MU6zpS4HGFFM71NtrseoTsnGmoP63uH00NKTYRIqt+P3s/FfSlnDf0d6y/tPlPpXCCGjyj2SxCfjYTA==
- In-reply-to: <08fda202-ce07-4ec7-907f-2dfae3a38215@www.fastmail.com>
- 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
- References: <93184-1569577244.094968@Wtq1.Nz_l.UBa8> <08fda202-ce07-4ec7-907f-2dfae3a38215@www.fastmail.com>
"Daniel Shahaf" wrote:
> Oliver Kiddle wrote on Fri, 27 Sep 2019 09:40 +00:00:
> > ssh, multiple -t options force tty allocation, even if ssh has no local
> > tty. So I'm not sure there's any meaning to specifying it more than
> > twice but _arguments doesn't provide an easy way to indicate that.
> >
>
> (untested) How about:
>
> '(-t -tt)-T[disable pseudo-tty allocation]' \
> '(-T)-t[force pseudo-tty allocation]' \
> "(-T)-tt[force pseudo-tty allocation even if have no controlling tty]" \
There are some cases where we've used that form. The disadvantage is
that it bloats the option/description listing. The shorter it is, the
more chance you have of finding what you're looking for. And given
that -tt will be rare from the command-line rather than a script, I'm
reluctant to add it here in that form. Note that with that form, -tt
should exclude -t and arguably also -t can exclude -tt.
It is also possible to check whether we already have a -t on the command
line and alter the description accordingly. As in the following patch.
The pattern for this has limitations as a t might appear in an argument
to another option. We don't have opt_args before _arguments has been
called.
I also noticed another case of unmarked repeatable options, this time in
_dsh.
Oliver
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index f8f4e0091..df1fe6ca8 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -4,7 +4,7 @@
_ssh () {
local curcontext="$curcontext" state line expl suf ret=1
- local args common common_transfer algopt tmp p1 file cmn cmds sdesc
+ local args common common_transfer algopt tmp p1 file cmn cmds sdesc tdesc
typeset -A opt_args
common=(
@@ -30,6 +30,7 @@ _ssh () {
case "$service" in
ssh)
+ (( $+words[(r)-[^-]#t*] )) && tdesc=' even if there is no controlling tty'
_arguments -C -s \
'(-a)-A[enable forwarding of the authentication agent connection]' \
'(-A)-a[disable forwarding of authentication agent connection]' \
@@ -60,7 +61,7 @@ _ssh () {
'-Q+[query parameters]:query option:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" mac\:"supported message integrity codes" kex\:"key exchange algorithms" key\:"key types" key-cert\:"certificate key types" key-plain\:"non-certificate key types" protocol-version\:"supported SSH protocol versions" sig\:"supported signature algorithms" help\:"show supported queries"))' \
'-s[invoke subsystem]' \
'(-t)-T[disable pseudo-tty allocation]' \
- '(-T)-t[force pseudo-tty allocation]' \
+ "(-T)*-t[force pseudo-tty allocation${tdesc}]" \
'-V[show version number]' \
'(-q)*-v[verbose mode (multiple increase verbosity, up to 3)]' \
'-W+[forward standard input and output to host]:stdinout forward:->hostport' \
diff --git a/Completion/Unix/Command/_dsh b/Completion/Unix/Command/_dsh
index fc7680062..2486b23fd 100644
--- a/Completion/Unix/Command/_dsh
+++ b/Completion/Unix/Command/_dsh
@@ -10,10 +10,10 @@ _arguments -s -C -S \
'(-M --show-machine-names)'{-M,--show-machine-names}'[prepend the host name on output]' \
'(-i --duplicate-input)'{-i,--duplicate-input}'[duplicate input given to dsh]' \
'(-b --bufsize)'{-b,--bufsize}'[change buffer size used in input duplication]:buffer size for -i (bytes)' \
- '(-m --machine)'{-m,--machine}'[execute on machine]:machine:{_hosts || _user_at_host}' \
+ \*{-m,--machine}'[execute on machine]:machine:{_hosts || _user_at_host}' \
'(-n --num-topology)'{-n,--num-topology}'[how to divide the machines]:number' \
'(-a --all)'{-a,--all}'[execute on all machines]' \
- '(-g --group)'{-g,--group}'[execute on group member]:groupname:->groups' \
+ \*{-g,--group}'[execute on group member]:groupname:->groups' \
'(-f --file)'{-f,--file}'[use the file as list of machines]:file:_files' \
'(-r --remoteshell)'{-r,--remoteshell}'[execute using shell]:remote shell:(rsh ssh)' \
'(-o --remoteshellopt)'{-o,--remoteshellopt}'[option to give to remote shell ]:option' \
Messages sorted by:
Reverse Date,
Date,
Thread,
Author