diff --git a/CHANGES b/CHANGES index 1ae6a04d..48de2681 100644 --- a/CHANGES +++ b/CHANGES @@ -24,7 +24,8 @@ bash-completion (2.x) * Apply pine completion to alpine too. * Remove many unnecessary short option completions where long ones exist. * Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer, - mysqladmin, screen, service, scp, ssh, and general hostname completions. + mysqladmin, screen, service, scp, ssh, update-alternatives, and general + hostname completions. * Add abook and wtf completion, based on work by Raphaƫl Droz. * Add jarsigner, k3b, lftpget, pack200 and unpack200 completions. * Don't overwrite other host completions when completing from multiple diff --git a/contrib/update-alternatives b/contrib/update-alternatives index 6a3f541d..8694ea26 100644 --- a/contrib/update-alternatives +++ b/contrib/update-alternatives @@ -30,14 +30,14 @@ _update_alternatives() _filedir -d return 0 ;; - --help|--version) + --help|--usage|--version) return 0 ;; esac # find which mode to use and how many real args used so far for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then + if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then mode=${COMP_WORDS[i]} args=$(($COMP_CWORD - i)) break @@ -47,18 +47,30 @@ _update_alternatives() case $mode in --install) case $args in - 1) + 1|3) _filedir ;; 2) _installed_alternatives ;; - 3) - _filedir + 4) + # priority - no completions ;; + *) + case $((args % 4)) in + 0|2) + _filedir + ;; + 1) + COMPREPLY=( $( compgen -W '--slave' -- "$cur" ) ) + ;; + 3) + _installed_alternatives + ;; + esac esac ;; - --remove) + --remove|--set) case $args in 1) _installed_alternatives @@ -68,23 +80,13 @@ _update_alternatives() ;; esac ;; - --auto) - _installed_alternatives - ;; - --remove-all) - _installed_alternatives - ;; - --display) - _installed_alternatives - ;; - --config) + --auto|--remove-all|--display|--config) _installed_alternatives ;; *) COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \ - --altdir --admindir' -- "$cur" ) \ - $( compgen -W '--install --remove --auto --display \ - --config' -- "$cur" ) ) + --altdir --admindir --install --remove --auto --display \ + --config --set' -- "$cur" ) ) esac } complete -F _update_alternatives update-alternatives alternatives