Skip to content

Commit ccf1388

Browse files
committed
fix(cvs,ssh): deprecate existing funcs favoring xfunc (fixup 192b60a)
1 parent 21f5a61 commit ccf1388

File tree

2 files changed

+34
-55
lines changed

2 files changed

+34
-55
lines changed

completions/cvs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# cvs(1) completion -*- shell-script -*-
22

3-
_comp_xfunc_cvs_roots()
4-
{
5-
_cvs_roots
6-
}
7-
83
_cvs_entries()
94
{
105
local prefix=${cur%/*}/ IFS=$'\n'
@@ -40,7 +35,7 @@ _cvs_kflags()
4035
COMPREPLY=($(compgen -W 'kv kvl k o b v' -- "$cur"))
4136
}
4237

43-
_cvs_roots()
38+
_comp_xfunc_cvs_roots()
4439
{
4540
local -a cvsroots
4641
[[ -v CVSROOT ]] && cvsroots=("$CVSROOT")
@@ -50,6 +45,8 @@ _cvs_roots()
5045
__ltrim_colon_completions "$cur"
5146
}
5247

48+
_comp_deprecate_func _cvs_roots _comp_xfunc_cvs_roots
49+
5350
_cvs()
5451
{
5552
local cur prev words cword
@@ -278,7 +275,7 @@ _cvs()
278275
fi
279276
;;
280277
cvsroot)
281-
_cvs_roots
278+
_comp_xfunc_cvs_roots
282279
;;
283280
diff | log | status)
284281
if [[ $cur == -* ]]; then

completions/ssh

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
11
# ssh(1) completion -*- shell-script -*-
22

3-
_comp_xfunc_ssh_query()
4-
{
5-
_ssh_query "$@"
6-
}
7-
8-
_comp_xfunc_ssh_options()
9-
{
10-
_ssh_options "$@"
11-
}
12-
13-
_comp_xfunc_ssh_suboption_check()
14-
{
15-
_ssh_suboption_check "$@"
16-
}
17-
18-
_comp_xfunc_ssh_identityfile()
19-
{
20-
_ssh_identityfile "$@"
21-
}
22-
23-
_comp_xfunc_ssh_scp_remote_files()
24-
{
25-
_scp_remote_files "$@"
26-
}
27-
28-
_comp_xfunc_ssh_scp_local_files()
29-
{
30-
_scp_local_files "$@"
31-
}
32-
333
_ssh_queries()
344
{
355
local queries=$(_comp_xfunc_ssh_query "$1" help)
@@ -40,11 +10,13 @@ _ssh_queries()
4010
COMPREPLY+=($(compgen -W "$queries help" -- "${cur,,}"))
4111
}
4212

43-
_ssh_query()
13+
_comp_xfunc_ssh_query()
4414
{
4515
${1:-ssh} -Q $2 2>/dev/null
4616
}
4717

18+
_comp_deprecate_func _ssh_query _comp_xfunc_ssh_query
19+
4820
_ssh_ciphers()
4921
{
5022
local ciphers=$(_comp_xfunc_ssh_query "$1" cipher)
@@ -62,7 +34,7 @@ _ssh_macs()
6234
COMPREPLY+=($(compgen -W "$macs" -- "$cur"))
6335
}
6436

65-
_ssh_options()
37+
_comp_xfunc_ssh_options()
6638
{
6739
# 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
6840
local opts=(
@@ -111,6 +83,8 @@ _ssh_options()
11183
$reset
11284
}
11385

86+
_comp_deprecate_func _ssh_options _comp_xfunc_ssh_options
87+
11488
# Complete a ssh suboption (like ForwardAgent=y<tab>)
11589
# Two parameters: the string to complete including the equal sign, and
11690
# the ssh executable to invoke (optional).
@@ -151,7 +125,7 @@ _ssh_suboption()
151125
COMPREPLY=($(compgen -W 'yes no always' -- "$cur"))
152126
;;
153127
identityfile)
154-
_ssh_identityfile
128+
_comp_xfunc_ssh_identityfile
155129
;;
156130
*file | identityagent | include | controlpath | revokedhostkeys | \
157131
xauthlocation)
@@ -240,7 +214,7 @@ _ssh_suboption()
240214
# Try to complete -o SubOptions=
241215
#
242216
# Returns 0 if the completion was handled or non-zero otherwise.
243-
_ssh_suboption_check()
217+
_comp_xfunc_ssh_suboption_check()
244218
{
245219
# Get prev and cur words without splitting on =
246220
local cureq=$(_get_cword :=) preveq=$(_get_pword :=)
@@ -251,6 +225,8 @@ _ssh_suboption_check()
251225
return 1
252226
}
253227

228+
_comp_deprecate_func _ssh_suboption_check _comp_xfunc_ssh_suboption_check
229+
254230
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
255231
_ssh_configfile()
256232
{
@@ -271,7 +247,7 @@ _ssh_configfile()
271247

272248
# With $1 set, look for public key files, else private
273249
# shellcheck disable=SC2120
274-
_ssh_identityfile()
250+
_comp_xfunc_ssh_identityfile()
275251
{
276252
[[ -z $cur && -d ~/.ssh ]] && cur=~/.ssh/id
277253
_filedir
@@ -281,6 +257,8 @@ _ssh_identityfile()
281257
fi
282258
}
283259

260+
_comp_deprecate_func _ssh_identityfile _comp_xfunc_ssh_identityfile
261+
284262
_ssh()
285263
{
286264
local cur prev words cword
@@ -289,7 +267,7 @@ _ssh()
289267
local configfile
290268
_ssh_configfile
291269

292-
_ssh_suboption_check "$1" && return
270+
_comp_xfunc_ssh_suboption_check "$1" && return
293271

294272
local ipvx
295273

@@ -320,7 +298,7 @@ _ssh()
320298
return
321299
;;
322300
-*i)
323-
_ssh_identityfile
301+
_comp_xfunc_ssh_identityfile
324302
return
325303
;;
326304
-*J)
@@ -340,7 +318,7 @@ _ssh()
340318
return
341319
;;
342320
-*o)
343-
_ssh_options "$1"
321+
_comp_xfunc_ssh_options "$1"
344322
return
345323
;;
346324
-*Q)
@@ -392,7 +370,7 @@ _sftp()
392370
local configfile
393371
_ssh_configfile
394372

395-
_ssh_suboption_check && return
373+
_comp_xfunc_ssh_suboption_check && return
396374

397375
local ipvx
398376

@@ -405,7 +383,7 @@ _sftp()
405383
return
406384
;;
407385
-*i)
408-
_ssh_identityfile
386+
_comp_xfunc_ssh_identityfile
409387
return
410388
;;
411389
-*c)
@@ -417,7 +395,7 @@ _sftp()
417395
return
418396
;;
419397
-*o)
420-
_ssh_options
398+
_comp_xfunc_ssh_options
421399
return
422400
;;
423401
-*S)
@@ -454,7 +432,7 @@ _scp_path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
454432
# Complete remote files with ssh. If the first arg is -d, complete on dirs
455433
# only. Returns paths escaped with three backslashes.
456434
# shellcheck disable=SC2120
457-
_scp_remote_files()
435+
_comp_xfunc_ssh_scp_remote_files()
458436
{
459437
local IFS=$'\n'
460438

@@ -492,11 +470,13 @@ _scp_remote_files()
492470
COMPREPLY+=($files)
493471
}
494472

473+
_comp_deprecate_func _scp_remote_files _comp_xfunc_ssh_scp_remote_files
474+
495475
# This approach is used instead of _filedir to get a space appended
496476
# after local file/dir completions, and -o nospace retained for others.
497477
# If first arg is -d, complete on directory names only. The next arg is
498478
# an optional prefix to add to returned completions.
499-
_scp_local_files()
479+
_comp_xfunc_ssh_scp_local_files()
500480
{
501481
local IFS=$'\n'
502482

@@ -517,6 +497,8 @@ _scp_local_files()
517497
fi
518498
}
519499

500+
_comp_deprecate_func _scp_local_files _comp_xfunc_ssh_scp_local_files
501+
520502
# scp(1) completion
521503
#
522504
_scp()
@@ -527,7 +509,7 @@ _scp()
527509
local configfile
528510
_ssh_configfile
529511

530-
_ssh_suboption_check && {
512+
_comp_xfunc_ssh_suboption_check && {
531513
COMPREPLY=("${COMPREPLY[@]/%/ }")
532514
return
533515
}
@@ -546,7 +528,7 @@ _scp()
546528
return
547529
;;
548530
-*i)
549-
_ssh_identityfile
531+
_comp_xfunc_ssh_identityfile
550532
compopt +o nospace
551533
return
552534
;;
@@ -558,7 +540,7 @@ _scp()
558540
return
559541
;;
560542
-*o)
561-
_ssh_options
543+
_comp_xfunc_ssh_options
562544
return
563545
;;
564546
-*S)
@@ -579,7 +561,7 @@ _scp()
579561
case $cur in
580562
!(*:*)/* | [.~]*) ;; # looks like a path
581563
*:*)
582-
_scp_remote_files
564+
_comp_xfunc_ssh_scp_remote_files
583565
return
584566
;;
585567
esac
@@ -607,7 +589,7 @@ _scp()
607589
esac
608590
fi
609591

610-
_scp_local_files "${prefix-}"
592+
_comp_xfunc_ssh_scp_local_files "${prefix-}"
611593
} &&
612594
complete -F _scp -o nospace scp
613595

0 commit comments

Comments
 (0)