[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 733811a7b14f7a510f99977e41d97afa353603c6

Ville Skyttä ville.skytta at iki.fi
Thu Dec 10 22:40:18 UTC 2009


The following commit has been merged in the master branch:
commit 8f68300a0d97e9e9b3d2cd8740519d2e29233754
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Fri Dec 11 00:14:54 2009 +0200

    Add wordbreak filtering to _count_args.

diff --git a/bash_completion b/bash_completion
index 7e3403c..55c8919 100644
--- a/bash_completion
+++ b/bash_completion
@@ -728,15 +728,16 @@ _realcommand() {
 
 
 # This function counts the number of args
-#
+# @param $1 chars  Characters out of $COMP_WORDBREAKS which should
+#     NOT be considered word breaks. See __reassemble_comp_words_by_ref.
 _count_args()
 {
-    local i
+    local i cword words
+    __reassemble_comp_words_by_ref "$1" words cword
+
     args=1
-    for (( i=1; i < COMP_CWORD; i++ )); do
-        if [[ "${COMP_WORDS[i]}" != -* ]]; then
-            args=$(($args+1))
-        fi
+    for i in "${words[@]:1:cword-1}"; do
+        [[ "$i" != -* ]] && args=$(($args+1))
     done
 }
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list