[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 8ef975797dfdb09160ad74c8ac0994d1c0623b02

Ville Skyttä ville.skytta at iki.fi
Mon Oct 19 21:12:56 UTC 2009


The following commit has been merged in the master branch:
commit 8ef975797dfdb09160ad74c8ac0994d1c0623b02
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Tue Oct 20 00:12:49 2009 +0300

    Use _split_longopt in mdadm.

diff --git a/CHANGES b/CHANGES
index 9f22f0f..0380ff6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -15,7 +15,7 @@ bash-completion (1.x)
   * Apply cardctl completion to pccardctl too.
   * Apply pine completion to alpine too.
   * Remove many unnecessary short option completions where long ones exist.
-  * Improve gkrellm completion.
+  * Improve gkrellm and mdadm completions.
   * Add wtf completion, based on work by Raphaël Droz.
 
  -- David Paleino <d.paleino at gmail.com>  Sun, 11 Oct 2009 11:11:57 +0200
diff --git a/contrib/mdadm b/contrib/mdadm
index 83f3f14..a2a88ea 100644
--- a/contrib/mdadm
+++ b/contrib/mdadm
@@ -1,6 +1,7 @@
 # bash completion for mdadm
 
-have mdadm && {
+have mdadm &&
+{
 _mdadm_raid_level()
 {
     local mode
@@ -71,68 +72,41 @@ _mdadm_update_flag()
 
 _mdadm()
 {
-    local cur prev mode options
+    local cur prev mode options split=false
 
     COMPREPLY=()
     cur=`_get_cword`
     prev=${COMP_WORDS[COMP_CWORD-1]}
 
-    # --name value style option
+    _split_longopt && split=true
+
     case $prev in
-        -@(c|b))
+        -c|--config|-b|--bitmap|--backup-file)
             _filedir
             return 0
             ;;
-        -l)
+        -l|--level)
             _mdadm_raid_level
             return 0
             ;;
-        -p)
+        -p|--layout|--parity)
             _mdadm_raid_layout
             return 0
             ;;
-        -a)
+        -a|--auto)
             _mdadm_auto_flag
             return 0
             ;;
-        -U)
+        -U|--update)
             _mdadm_update_flag
             return 0
             ;;
     esac
 
-    # TODO: use _split_longopt
-
-    # --name=value style option
-    if [[ "$cur" == *=* ]]; then
-        prev=${cur/=*/}
-        cur=${cur/*=/}
-        case "$prev" in
-        --@(config|bitmap|backup-file))
-            _filedir
-            return 0
-            ;;
-        --level)
-            _mdadm_raid_level
-            return 0
-            ;;
-        --@(layout|parity))
-            _mdadm_raid_layout
-            return 0
-            ;;
-        --auto)
-            _mdadm_auto_flag
-            return 0
-            ;;
-        --update)
-            _mdadm_update_flag
-            return 0
-            ;;
-        esac
-    fi
+    $split && return 0
 
     options='--help --help-options --version --verbose --quiet \
-        --brief --force --config= --scan --metadata= --homehost='
+        --brief --force --config --scan --metadata --homehost'
 
     if [[ "$cur" == -* ]]; then
         if [[ $COMP_CWORD -eq 1 ]] ; then
@@ -141,17 +115,17 @@ _mdadm()
         else
             case ${COMP_WORDS[COMP_CWORD-1]} in
                 -@(A|-assemble))
-                    COMPREPLY=( $( compgen -W "$options --uuid= \
-                        --super-minor= --name= --force --run \
-                        --no-degraded --auto --bitmap= --backup-file= \
-                        --update= --auto-update-homehost" -- "$cur" ) )
+                    COMPREPLY=( $( compgen -W "$options --uuid \
+                        --super-minor --name --force --run \
+                        --no-degraded --auto --bitmap --backup-file \
+                        --update --auto-update-homehost" -- "$cur" ) )
                     ;;
                 -@(B|C|G|-build|-create|-grow))
-                    COMPREPLY=( $( compgen -W "$options --raid-devices= \
-                        --spare-devices= --size= --chunk= --rounding= \
-                        --level= --layout= --parity= --bitmap= \
-                        --bitmap-chunk= --write-mostly --write-behind= \
-                        --assume-clean --backup-file= --name= --run \
+                    COMPREPLY=( $( compgen -W "$options --raid-devices \
+                        --spare-devices --size --chunk --rounding \
+                        --level --layout --parity --bitmap \
+                        --bitmap-chunk --write-mostly --write-behind \
+                        --assume-clean --backup-file --name --run \
                         --force --auto" -- "$cur" ) )
                     ;;
                 -@(F|-follow|-monitor))

-- 
bash-completion



More information about the Bash-completion-commits mailing list