Skip to content

Commit 56f9bff

Browse files
committed
refactor(ssh): convert xfunc options to a generator
1 parent 655126b commit 56f9bff

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

completions/mussh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ _comp_cmd_mussh()
2222
return
2323
;;
2424
-o | -po)
25-
_comp_xfunc ssh options
25+
_comp_compgen -x ssh options
2626
return
2727
;;
2828
-l | -L)

completions/ssh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ _comp_cmd_ssh__compgen_macs()
5050
}
5151

5252
# @since 2.12
53-
# TODO:API: make it a generator
54-
_comp_xfunc_ssh_options()
53+
_comp_xfunc_ssh_compgen_options()
5554
{
5655
# curl --silent https://raw.githubusercontent.com/openssh/openssh-portable/master/ssh_config.5 | awk '$1==".It" && $2=="Cm" && $3!="Host" && $3!="Match" {print " "$3}' | sort
57-
local opts=(
56+
local _opts=(
5857
AddKeysToAgent AddressFamily BatchMode BindAddress BindInterface
5958
CanonicalDomains CanonicalizeFallbackLocal CanonicalizeHostname
6059
CanonicalizeMaxDots CanonicalizePermittedCNAMEs CASignatureAlgorithms
@@ -80,28 +79,29 @@ _comp_xfunc_ssh_options()
8079
UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation
8180
)
8281
# Selected old ones
83-
opts+=(
82+
_opts+=(
8483
GSSAPIKeyExchange GSSAPIRenewalForcesRekey GSSAPIServerIdentity
8584
GSSAPITrustDns PubkeyAcceptedKeyTypes SmartcardDevice UsePrivilegedPort
8685
)
8786
local -a protocols
8887
_comp_compgen -v protocols -i ssh query ssh protocol-version
8988
if [[ ${protocols[*]-} == *1* ]]; then
90-
opts+=(Cipher CompressionLevel Protocol RhostsRSAAuthentication
89+
_opts+=(Cipher CompressionLevel Protocol RhostsRSAAuthentication
9190
RSAAuthentication)
9291
fi
92+
_comp_unlocal protocols
9393

9494
compopt -o nospace
95-
local IFS=$' \t\n' reset=$(shopt -p nocasematch)
96-
shopt -s nocasematch
97-
local option
98-
COMPREPLY=($(for option in "${opts[@]}"; do
99-
[[ $option == "$cur"* ]] && printf '%s=\n' "$option"
100-
done))
101-
$reset
95+
_comp_compgen_split -l -- "$(
96+
shopt -s nocasematch
97+
local option
98+
for option in "${_opts[@]}"; do
99+
[[ $option == "$cur"* ]] && printf '%s=\n' "$option"
100+
done
101+
)"
102102
}
103103

104-
_comp_deprecate_func 2.12 _ssh_options _comp_xfunc_ssh_options
104+
_comp_deprecate_func 2.12 _ssh_options _comp_xfunc_ssh_compgen_options
105105

106106
# Complete a ssh suboption (like ForwardAgent=y<tab>)
107107
# @param $1 the ssh executable to invoke
@@ -351,7 +351,7 @@ _comp_cmd_ssh()
351351
return
352352
;;
353353
-*o)
354-
_comp_xfunc_ssh_options "$1"
354+
_comp_xfunc_ssh_compgen_options "$1"
355355
return
356356
;;
357357
-*Q)
@@ -431,7 +431,7 @@ _comp_cmd_sftp()
431431
return
432432
;;
433433
-*o)
434-
_comp_xfunc_ssh_options
434+
_comp_xfunc_ssh_compgen_options
435435
return
436436
;;
437437
-*S)
@@ -585,7 +585,7 @@ _comp_cmd_scp()
585585
return
586586
;;
587587
-*o)
588-
_comp_xfunc_ssh_options
588+
_comp_xfunc_ssh_compgen_options
589589
return
590590
;;
591591
-*S)

completions/ssh-copy-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _comp_cmd_ssh_copy_id()
2020
return
2121
;;
2222
-o)
23-
_comp_xfunc ssh options
23+
_comp_compgen -x ssh options
2424
return
2525
;;
2626
esac

0 commit comments

Comments
 (0)