Skip to content

Commit 4605edf

Browse files
authored
Merge pull request #1035 from akinomyoga/refactor-api-4
refactor: API/naming of other functions in `bash_completion`
2 parents 0661fb5 + d2860cb commit 4605edf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+353
-272
lines changed

bash_completion

Lines changed: 120 additions & 96 deletions
Large diffs are not rendered by default.

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ _comp_deprecate_func 2.12 _root_command _comp_root_command
1010
_comp_deprecate_func 2.12 _xfunc _comp_xfunc
1111
_comp_deprecate_func 2.12 _upvars _comp_upvars
1212
_comp_deprecate_func 2.12 _get_comp_words_by_ref _comp_get_words
13+
_comp_deprecate_func 2.12 _known_hosts_real _comp_compgen_known_hosts
1314
_comp_deprecate_func 2.12 _longopt _comp_longopt
1415
_comp_deprecate_func 2.12 __ltrim_colon_completions _comp_ltrim_colon_completions
16+
_comp_deprecate_func 2.12 _variables _comp_compgen_variables
1517
_comp_deprecate_func 2.12 _signals _comp_compgen_signals
1618
_comp_deprecate_func 2.12 _mac_addresses _comp_compgen_mac_addresses
1719
_comp_deprecate_func 2.12 _available_interfaces _comp_compgen_available_interfaces
@@ -21,6 +23,9 @@ _comp_deprecate_func 2.12 _kernel_versions _comp_compgen_kernel_versions
2123
_comp_deprecate_func 2.12 _uids _comp_compgen_uids
2224
_comp_deprecate_func 2.12 _gids _comp_compgen_gids
2325
_comp_deprecate_func 2.12 _xinetd_services _comp_compgen_xinetd_services
26+
_comp_deprecate_func 2.12 _services _comp_compgen_services
27+
_comp_deprecate_func 2.12 _bashcomp_try_faketty _comp_try_faketty
28+
_comp_deprecate_func 2.12 _expand _comp_expand
2429
_comp_deprecate_func 2.12 _pids _comp_compgen_pids
2530
_comp_deprecate_func 2.12 _pgids _comp_compgen_pgids
2631
_comp_deprecate_func 2.12 _pnames _comp_compgen_pnames
@@ -359,6 +364,26 @@ _ncpus()
359364
printf %s "$ret"
360365
}
361366

367+
# Expand variable starting with tilde (~).
368+
# We want to expand ~foo/... to /home/foo/... to avoid problems when
369+
# word-to-complete starting with a tilde is fed to commands and ending up
370+
# quoted instead of expanded.
371+
# Only the first portion of the variable from the tilde up to the first slash
372+
# (~../) is expanded. The remainder of the variable, containing for example
373+
# a dollar sign variable ($) or asterisk (*) is not expanded.
374+
#
375+
# @deprecated 2.12 Use `_comp_expand_tilde`. The new function receives the
376+
# value instead of a variable name as $1 and always returns the result to the
377+
# variable `ret`.
378+
__expand_tilde_by_ref()
379+
{
380+
[[ ${1+set} ]] || return 0
381+
[[ $1 == ret ]] || local ret
382+
_comp_expand_tilde "${!1-}"
383+
# shellcheck disable=SC2059
384+
[[ $1 == ret ]] || printf -v "$1" "$ret"
385+
} # __expand_tilde_by_ref()
386+
362387
# @deprecated 2.12 Use `_comp_compgen -a cd_devices`
363388
_cd_devices()
364389
{
@@ -401,6 +426,12 @@ _allowed_groups()
401426
_comp_compgen -c "${1:-$cur}" allowed_groups
402427
}
403428

429+
# @deprecated 2.12 Use `_comp_compgen -a shells`
430+
_shells()
431+
{
432+
_comp_compgen -a shells
433+
}
434+
404435
# @deprecated 2.12 Use `_comp_compgen -a fstypes`
405436
_fstypes()
406437
{

completions/_chsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _comp_cmd_chsh()
2626
return
2727
;;
2828
-s | --shell)
29-
_shells "${chroot-}"
29+
_comp_compgen_shells "${chroot-}"
3030
return
3131
;;
3232
esac

completions/_su

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _comp_cmd_su()
1515

1616
case "$prev" in
1717
-s | --shell)
18-
_shells
18+
_comp_compgen_shells
1919
return
2020
;;
2121
-c | --command | --session-command)

completions/_xm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ _comp_cmd_xm()
9393
_comp_cmd_xm__domain_names
9494
;;
9595
3)
96-
_known_hosts_real -- "$cur"
96+
_comp_compgen_known_hosts -- "$cur"
9797
;;
9898
esac
9999
;;

completions/arping

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _comp_cmd_arping()
2424
return
2525
fi
2626

27-
_known_hosts_real -- "$cur"
27+
_comp_compgen_known_hosts -- "$cur"
2828
} &&
2929
complete -F _comp_cmd_arping arping
3030

completions/arpspoof

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ _comp_cmd_arpspoof()
1111
return
1212
;;
1313
-t)
14-
_known_hosts_real -- "$cur"
14+
_comp_compgen_known_hosts -- "$cur"
1515
return
1616
;;
1717
esac
1818

1919
if [[ $cur == -* ]]; then
2020
_comp_compgen_usage
2121
else
22-
_known_hosts_real -- "$cur"
22+
_comp_compgen_known_hosts -- "$cur"
2323
fi
2424

2525
} &&

completions/cancel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _comp_cmd_cancel()
77

88
case $prev in
99
-h)
10-
_known_hosts_real -- "$cur"
10+
_comp_compgen_known_hosts -- "$cur"
1111
return
1212
;;
1313
-U)

completions/chkconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _comp_cmd_chkconfig()
77

88
case $prev in
99
--level=[1-6] | [1-6] | --list | --add | --del | --override)
10-
_services
10+
_comp_compgen_services
1111
_comp_compgen -a xinetd_services
1212
return
1313
;;
@@ -25,7 +25,7 @@ _comp_cmd_chkconfig()
2525
if ((cword == 2 || cword == 4)); then
2626
_comp_compgen -- -W 'on off reset resetpriorities'
2727
else
28-
_services
28+
_comp_compgen_services
2929
_comp_compgen -a xinetd_services
3030
fi
3131
fi

completions/chromium-browser

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _comp_cmd_chromium_browser()
1717
case $cur in
1818
*://*)
1919
local prefix="${cur%%://*}://"
20-
_known_hosts_real -- "${cur#*://}"
20+
_comp_compgen_known_hosts -- "${cur#*://}"
2121
COMPREPLY=("${COMPREPLY[@]/#/$prefix}")
2222
_comp_ltrim_colon_completions "$cur"
2323
;;

0 commit comments

Comments
 (0)