Skip to content

Commit 9078d37

Browse files
committed
refactor(ssh): convert xfunc suboption_check to a generator
1 parent 56f9bff commit 9078d37

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

completions/ssh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ _comp_deprecate_func 2.12 _ssh_options _comp_xfunc_ssh_compgen_options
108108
# @param $2 the string to complete including the equal sign
109109
# Not all suboptions are completed.
110110
# Doesn't handle comma-separated lists.
111-
_comp_cmd_ssh__suboption()
111+
_comp_cmd_ssh__compgen_suboption()
112112
{
113113
# Split into subopt and subval
114-
local prev=${2%%=*} cur=${2#*=}
114+
local _prev=${2%%=*} cur=${2#*=}
115115

116-
case ${prev,,} in
116+
case ${_prev,,} in
117117
batchmode | canonicaldomains | canonicalizefallbacklocal | \
118118
challengeresponseauthentication | checkhostip | \
119119
clearallforwardings | controlpersist | compression | \
@@ -233,29 +233,29 @@ _comp_cmd_ssh__suboption()
233233
#
234234
# Returns 0 if the completion was handled or non-zero otherwise.
235235
# @since 2.12
236-
# # TODO:API: make it a generator
237-
_comp_xfunc_ssh_suboption_check()
236+
_comp_xfunc_ssh_compgen_suboption_check()
238237
{
239-
_comp_cmd_ssh__suboption_check ssh
238+
_comp_cmd_ssh__compgen_suboption_check ssh
240239
}
241240

242241
# @param $1 the ssh executable to invoke
243-
_comp_cmd_ssh__suboption_check()
242+
_comp_cmd_ssh__compgen_suboption_check()
244243
{
245244
# Get prev and cur words without splitting on =
246245
local cur prev
247246
_comp_get_words -n := cur prev
248247
if [[ $cur == *=* && $prev == -*o ]]; then
249-
_comp_cmd_ssh__suboption "$1" "$cur"
248+
_comp_unlocal prev
249+
_comp_cmd_ssh__compgen_suboption "$1" "$cur"
250250
return $?
251251
fi
252252
return 1
253253
}
254254

255-
# @deprecated 2.12 use `_comp_xfunc_ssh_suboption_check` instead
255+
# @deprecated 2.12 use `_comp_xfunc_ssh_compgen_suboption_check` instead
256256
_ssh_suboption_check()
257257
{
258-
_comp_cmd_ssh__suboption_check "${1:-ssh}"
258+
_comp_cmd_ssh__compgen_suboption_check "${1:-ssh}"
259259
}
260260

261261
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
@@ -300,7 +300,7 @@ _comp_cmd_ssh()
300300
local configfile
301301
_comp_cmd_ssh__configfile
302302

303-
_comp_cmd_ssh__suboption_check "$1" && return
303+
_comp_cmd_ssh__compgen_suboption_check "$1" && return
304304

305305
local ipvx
306306

@@ -406,7 +406,7 @@ _comp_cmd_sftp()
406406
local pathcmd
407407
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
408408

409-
_comp_xfunc_ssh_suboption_check && return
409+
_comp_xfunc_ssh_compgen_suboption_check && return
410410

411411
local ipvx=
412412

@@ -554,7 +554,7 @@ _comp_cmd_scp()
554554
local pathcmd
555555
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
556556

557-
_comp_xfunc_ssh_suboption_check && {
557+
_comp_xfunc_ssh_compgen_suboption_check && {
558558
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/%/ }")
559559
return
560560
}

completions/ssh-copy-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _comp_cmd_ssh_copy_id()
99
local pathcmd
1010
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
1111

12-
_comp_xfunc ssh suboption_check && return
12+
_comp_compgen -x ssh suboption_check && return
1313

1414
case $prev in
1515
-i)

0 commit comments

Comments
 (0)