[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 09045a63b642bfaaa11ed843e6fbbc6bcf907c4e

Ville Skyttä ville.skytta at iki.fi
Wed Dec 9 19:27:18 UTC 2009


The following commit has been merged in the master branch:
commit 09045a63b642bfaaa11ed843e6fbbc6bcf907c4e
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Dec 9 21:23:29 2009 +0200

    Add update-alternatives --set, --usage, and --slave completions, simplify some bits.

diff --git a/CHANGES b/CHANGES
index 1ae6a04..48de268 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 6a3f541..8694ea2 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

-- 
bash-completion



More information about the Bash-completion-commits mailing list