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

Freddy Vulto fvulto at gmail.com
Thu Dec 10 20:29:59 UTC 2009


The following commit has been merged in the master branch:
commit b1e58b1a0e4fdd88df3d1a3feae9adea8cc4e350
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Thu Dec 10 21:28:24 2009 +0100

    Fix __reassemble_comp_words_by_ref()
    If a word is made up of multiple word separator characters:
    
       $ a b::<TAB>  # CWORDS are: a, b, and :: (correct)
    
    __reassemble_comp_words_by_ref() couldn't handle this.  It assumed CWORDS were:
    
       $ a b::<TAB>  # CWORDS: a, b, : and : (but they're not)
    
    Added test case for this.  To run the automated tests:
    
       ./runUnit _get_cword.exp

diff --git a/bash_completion b/bash_completion
index d82b287..7e3403c 100644
--- a/bash_completion
+++ b/bash_completion
@@ -234,9 +234,9 @@ __reassemble_comp_words_by_ref() {
         # Yes, list of word completion separators has shrunk;
         # Re-assemble words to complete
         for (( i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
-            # Is current word not word 0 (the command itself) and is word of
-            # length 1 and is word newly excluded from being word separator?
-            while [[ $i -gt 0 && ${#COMP_WORDS[$i]} == 1 && ${COMP_WORDS[$i]//[^$exclude]} ]]; do
+            # Is current word not word 0 (the command itself) and is word made up of
+            # just word separators characters to be excluded?
+            while [[ $i -gt 0 && ${COMP_WORDS[$i]//[^$exclude]} ]]; do
                 [ $j -ge 2 ] && ((j--))
                 # Append word separator to current word
                 ref="$2[$j]"
diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp
index eaa62cb..cd2184e 100644
--- a/test/unit/_get_cword.exp
+++ b/test/unit/_get_cword.exp
@@ -171,6 +171,19 @@ assert_bash_list : $cmd $test
 sync_after_int
 
 
+set test {a b::| with WORDBREAKS -= : should return b::};  # | = cursor position
+if {[lindex $::BASH_VERSINFO 0] <= 3} {
+    set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1}
+} else {
+    set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
+}; # if
+append cmd {; COMP_LINE='a b::'; COMP_POINT=5; _get_cword :}
+assert_bash_list b:: $cmd $test
+
+
+sync_after_int
+
+
 # This test makes sure `_get_cword' doesn't use `echo' to return it's value,
 # because -n might be interpreted by `echo' and thus will not be returned.
 set test "a -n| should return -n";  # | = cursor position

-- 
bash-completion



More information about the Bash-completion-commits mailing list