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

Freddy Vulto fvulto at gmail.com
Wed Dec 30 08:45:00 UTC 2009


The following commit has been merged in the master branch:
commit 3251038c9da5ba469f85870fac05ff6e3a4b7852
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Wed Dec 30 09:43:16 2009 +0100

    Fix __reassemble_comp_words_by_ref()
    On bash-3, completing a b c: with COMP_WORDBREAKS -= : would result in the
    current word being bc: (Alioth #312190)
    
    Added unit test, run via:
    
        ./run unit/_get_cword.exp

diff --git a/bash_completion b/bash_completion
index 248bd25..7d313a6 100644
--- a/bash_completion
+++ b/bash_completion
@@ -228,8 +228,8 @@ __reassemble_comp_words_by_ref() {
         # 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 made up of
-            # just word separators characters to be excluded?
-            while [[ $i -gt 0 && ${COMP_WORDS[$i]//[^$exclude]} ]]; do
+            # just word separator characters to be excluded?
+            while [[ $i -gt 0 && ${COMP_WORDS[$i]//[^$exclude]} == ${COMP_WORDS[$i]} ]]; 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 7e38e9e..f71971b 100644
--- a/test/unit/_get_cword.exp
+++ b/test/unit/_get_cword.exp
@@ -161,6 +161,19 @@ assert_bash_list b:c $cmd $test
 sync_after_int
 
 
+set test {a b c:| with WORDBREAKS -= : should return c:};  # | = cursor position
+if {[lindex $::BASH_VERSINFO 0] <= 3} {
+    set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2}
+} else {
+    set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
+}; # if
+append cmd {; COMP_LINE='a b c:'; COMP_POINT=6; _get_cword :}
+assert_bash_list c: $cmd $test
+
+
+sync_after_int
+
+
 set test {a :| with WORDBREAKS -= : should return :};  # | = cursor position
 set cmd {COMP_WORDS=(a :); COMP_CWORD=1; COMP_LINE='a :'; COMP_POINT=3; _get_cword :}
 assert_bash_list : $cmd $test

-- 
bash-completion



More information about the Bash-completion-commits mailing list