diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
commit | 6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch) | |
tree | 0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions/sudo | |
parent | Releasing progress-linux version 1:2.11-8~progress7.99u1. (diff) | |
download | bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/sudo')
-rw-r--r-- | completions/sudo | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/completions/sudo b/completions/sudo index c9a806b..2cfcf84 100644 --- a/completions/sudo +++ b/completions/sudo @@ -1,56 +1,58 @@ # bash completion for sudo(8) -*- shell-script -*- -_sudo() +_comp_cmd_sudo() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return local i mode=normal [[ $1 == *sudoedit ]] && mode=edit + local noargopts='!(-*|*[uUgCp]*)' [[ $mode == normal ]] && for ((i = 1; i <= cword; i++)); do if [[ ${words[i]} != -* ]]; then local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin - local root_command=${words[i]} - _command_offset $i + local _comp_root_command=$1 + _comp_command_offset $i return fi - if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then + # shellcheck disable=SC2254 + if [[ ${words[i]} == -@(${noargopts}e*|-edit) ]]; then mode=edit break fi - [[ ${words[i]} == \ - -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] && + # shellcheck disable=SC2254 + [[ ${words[i]} == @(--@(user|other-user|group|close-from|prompt)|-${noargopts}[uUgCp]) ]] && ((i++)) done + # shellcheck disable=SC2254 case "$prev" in - --user | --other-user | -!(-*)[uU]) - COMPREPLY=($(compgen -u -- "$cur")) + --user | --other-user | -${noargopts}[uU]) + _comp_compgen -- -u return ;; - --group | -!(-*)g) - COMPREPLY=($(compgen -g -- "$cur")) + --group | -${noargopts}g) + _comp_compgen -- -g return ;; - --close-from | --prompt | -!(-*)[Cp]) + --close-from | --prompt | -${noargopts}[Cp]) return ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then - local opts=$(_parse_help "$1") - COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + _comp_compgen_help || _comp_compgen_usage [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi if [[ $mode == edit ]]; then - _filedir + _comp_compgen_filedir fi } && - complete -F _sudo sudo sudoedit + complete -F _comp_cmd_sudo sudo sudoedit # ex: filetype=sh |