Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adjust API/naming of generators #1029

Merged
merged 5 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ _comp_compgen_inserted_kernel_modules()
# context of current completion.
#
# @since 2.12
_comp_compgen_usergroup()
_comp_compgen_usergroups()
{
if [[ $cur == *\\\\* || $cur == *:*:* ]]; then
# Give up early on if something seems horribly wrong.
Expand All @@ -2017,16 +2017,19 @@ _comp_compgen_usergroup()
# Completing group after 'user\:gr<TAB>'.
# Reply with a list of groups prefixed with 'user:', readline will
# escape to the colon.
local _prefix
_prefix=${cur%%*([^:])}
_prefix=${_prefix//\\/}
local tmp
if [[ ${1-} == -u ]]; then
_comp_compgen -c "${cur#*:}" allowed_groups
_comp_compgen -v tmp -c "${cur#*:}" allowed_groups
else
_comp_compgen -c "${cur#*:}" -- -g
_comp_compgen -v tmp -c "${cur#*:}" -- -g
fi
if ((${#tmp[@]})); then
local _prefix=${cur%%*([^:])}
_prefix=${_prefix//\\/}
local -a _tmp=("${tmp[@]/#/$_prefix}")
_comp_unlocal tmp
_comp_compgen_set "${_tmp[@]}"
fi
((${#COMPREPLY[@]})) &&
COMPREPLY=("${COMPREPLY[@]/#/$_prefix}")
elif [[ $cur == *:* ]]; then
# Completing group after 'user:gr<TAB>'.
# Reply with a list of unprefixed groups since readline with split on :
Expand Down Expand Up @@ -2056,7 +2059,7 @@ _comp_compgen_allowed_users()
if _comp_as_root; then
_comp_compgen -- -u
else
_comp_compgen split -- "$(id -un 2>/dev/null || whoami 2>/dev/null)"
_comp_compgen_split -- "$(id -un 2>/dev/null || whoami 2>/dev/null)"
fi
}

Expand All @@ -2066,7 +2069,7 @@ _comp_compgen_allowed_groups()
if _comp_as_root; then
_comp_compgen -- -g
else
_comp_compgen split -- "$(id -Gn 2>/dev/null || groups 2>/dev/null)"
_comp_compgen_split -- "$(id -Gn 2>/dev/null || groups 2>/dev/null)"
fi
}

Expand Down Expand Up @@ -2110,7 +2113,7 @@ _comp_compgen_fstypes()
$([[ -d /etc/fs ]] && command ls /etc/fs)"
fi

[[ $_fss ]] && _comp_compgen -- -W "$_fss"
[[ $_fss ]] && _comp_compgen_split -- "$_fss"
}

# Get absolute path to a file, with rudimentary canonicalization.
Expand Down Expand Up @@ -2241,7 +2244,7 @@ _comp_compgen_dvd_devices()
# @since 2.12
_comp_compgen_terms()
{
_comp_compgen -a split -- "$({
_comp_compgen_split -- "$({
scop marked this conversation as resolved.
Show resolved Hide resolved
command sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap
{
toe -a || toe
Expand Down
9 changes: 7 additions & 2 deletions bash_completion.d/000_bash_completion_compat.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ _comp_deprecate_func 2.12 _kernel_versions _comp_compgen_kernel_versions
_comp_deprecate_func 2.12 _uids _comp_compgen_uids
_comp_deprecate_func 2.12 _gids _comp_compgen_gids
_comp_deprecate_func 2.12 _xinetd_services _comp_compgen_xinetd_services
_comp_deprecate_func 2.12 _terms _comp_compgen_terms
_comp_deprecate_func 2.12 _pids _comp_compgen_pids
_comp_deprecate_func 2.12 _pgids _comp_compgen_pgids
_comp_deprecate_func 2.12 _pnames _comp_compgen_pnames
_comp_deprecate_func 2.12 _modules _comp_compgen_kernel_modules
_comp_deprecate_func 2.12 _installed_modules _comp_compgen_inserted_kernel_modules
_comp_deprecate_func 2.12 _usergroup _comp_compgen_usergroup
_comp_deprecate_func 2.12 _usergroup _comp_compgen_usergroups
_comp_deprecate_func 2.12 _complete_as_root _comp_as_root

# Backwards compatibility for compat completions that use have().
Expand Down Expand Up @@ -380,6 +379,12 @@ _usb_ids()
_comp_compgen -a usb_ids
}

# @deprecated 2.12 Use `_comp_compgen -a terms`
_terms()
{
_comp_compgen -a terms
}

# @deprecated 2.12 Use `_comp_compgen -c "${prefix:-$cur}" allowed_users`
_allowed_users()
{
Expand Down
4 changes: 2 additions & 2 deletions completions/chown
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _comp_cmd_chown()

case "$prev" in
--from)
_comp_compgen_usergroup
_comp_compgen_usergroups
return
;;
--reference)
Expand All @@ -35,7 +35,7 @@ _comp_cmd_chown()
_comp_count_args :

if ((ret == 1)); then
_comp_compgen_usergroup -u
_comp_compgen_usergroups -u
else
_comp_compgen_filedir
fi
Expand Down
2 changes: 1 addition & 1 deletion completions/cpio
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _comp_cmd_cpio()
return
;;
--owner | -${noargopts}R)
_comp_compgen_usergroup
_comp_compgen_usergroups
return
;;
--rsh-command)
Expand Down
Loading