[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 29ee9fb3f973ad249806c1b412716330d76f06b2

Ville Skyttä ville.skytta at iki.fi
Sat Oct 31 12:12:53 UTC 2009


The following commit has been merged in the master branch:
commit 50b4b8459f6cf100d96b7720a40b1b9c1a02568a
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Oct 31 13:50:23 2009 +0200

    route(1) completion code cleanups.

diff --git a/contrib/net-tools b/contrib/net-tools
index b144762..a88aa2a 100644
--- a/contrib/net-tools
+++ b/contrib/net-tools
@@ -84,23 +84,18 @@ _route()
         return 0
     fi
 
-    COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
-        window irtt reject mod dyn reinstate dev \
-        default gw' -- "$cur" ) )
-
-    COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
-        (while read -d ' ' i; do
-            [ "$i" == "" ] && continue
-            # flatten array with spaces on either side,
-            # otherwise we cannot grep on word
-            # boundaries of first and last word
-            COMPREPLY=" ${COMPREPLY[@]} "
-            # remove word from list of completions
-            COMPREPLY=( ${COMPREPLY/ $i / } )
+    # Remove already given options from completions
+    local i found
+    for opt in add del -host -net netmask metric mss window irtt reject mod \
+        dyn reinstate dev default gw; do
+        found=false
+        for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
+            [ "${COMP_WORDS[i]}" = "$opt" ] && found=true && break
         done
-           echo "${COMPREPLY[@]}")
-        ) )
-    return 0
+        $found || COMPREPLY[${#COMPREPLY[@]}]="$opt"
+    done
+
+    COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
 } &&
 complete -F _route route
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list