diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.net.br> | 2019-08-07 09:17:13 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.net.br> | 2019-08-07 09:17:13 -0300 |
commit | 5732da2af736c40cf693354485446ab4867ecb4d (patch) | |
tree | 76d76cdfa16ca62d20fb109da13895ec64fff110 /completions/sudo | |
parent | 9cd22d1df8f0f5b554858471c86faa9f37b8fed4 (diff) | |
download | bash-completion-5732da2af736c40cf693354485446ab4867ecb4d.tar.gz |
New upstream version 2.9upstream/2.9
Diffstat (limited to 'completions/sudo')
-rw-r--r-- | completions/sudo | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/completions/sudo b/completions/sudo index 2fe1c001..1b8e508f 100644 --- a/completions/sudo +++ b/completions/sudo @@ -2,45 +2,49 @@ _sudo() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return local i mode=normal [[ $1 == *sudoedit ]] && mode=edit [[ $mode == normal ]] && - for (( i=1; i <= COMP_CWORD; i++ )); do - if [[ ${COMP_WORDS[i]} != -* ]]; then + for (( i=1; i <= cword; i++ )); do + if [[ ${words[i]} != -* ]]; then local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin - local root_command=${COMP_WORDS[i]} + local root_command=${words[i]} _command_offset $i return fi - if [[ ${COMP_WORDS[i]} == -e ]]; then + if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then mode=edit break fi - [[ ${COMP_WORDS[i]} == -[uUgCp] ]] && ((i++)) + [[ ${words[i]} == \ + -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] \ + && ((i++)) done case "$prev" in - -u|-U) - COMPREPLY=( $( compgen -u -- "$cur" ) ) + --user|--other-user|-!(-*)[uU]) + COMPREPLY=( $(compgen -u -- "$cur") ) return ;; - -g) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + --group|-!(-*)g) + COMPREPLY=( $(compgen -g -- "$cur") ) return ;; - -C|-p) - # argument required but no completions available + --close-from|--prompt|-!(-*)[Cp]) return ;; esac + $split && return + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-A -b -C -E -e -g -H -h -i -K -k -L -l -ll - -n -P -p -S -s -U -u -V -v' -- "$cur" ) ) + local opts=$(_parse_help "$1") + COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + [[ $COMPREPLY == *= ]] && compopt -o nospace return fi if [[ $mode == edit ]]; then |