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

Ville Skyttä ville.skytta at iki.fi
Tue Sep 28 15:30:15 UTC 2010


The following commit has been merged in the master branch:
commit 9341a1131cc9ed9e29d1e118819adb3d8dcf54a6
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Tue Sep 28 18:22:45 2010 +0300

    Fix known hosts completion for IPv6 addresses whose last 16 bits are digits (Alioth: #312695, RedHat: #630658).

diff --git a/CHANGES b/CHANGES
index 48d0f6a..6ccae2c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -22,6 +22,8 @@ bash-completion (2.x)
   * Drop bad kompare filename completion (Alioth: #312708).
   * Make _filedir and _filedir_xspec complete uppercase versions of their
     filename extension arguments in addition to exact case matches.
+  * Fix known hosts completion for IPv6 addresses whose last 16 bits are digits
+    (Alioth: #312695, RedHat: #630658).
 
   [ Freddy Vulto ]
   * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)
diff --git a/bash_completion b/bash_completion
index f7e1a28..98f35ca 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1298,8 +1298,7 @@ _known_hosts_real()
             COMPREPLY=( "${COMPREPLY[@]}" $( awk 'BEGIN {FS=","}
             /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
             gsub(" .*$", "", $i); \
-            gsub("[\\[\\]]", "", $i); \
-            gsub(":[0-9]+$", "", $i); \
+            sub("^\\[", "", $i); sub("\\](:[0-9]+)?$", "", $i); \
             if ($i ~ /'"$awkcur"'/) {print $i} \
             }}' "${kh[@]}" 2>/dev/null ) )
         fi
diff --git a/test/fixtures/_known_hosts_real/known_hosts b/test/fixtures/_known_hosts_real/known_hosts
index 07e20ec..6501909 100644
--- a/test/fixtures/_known_hosts_real/known_hosts
+++ b/test/fixtures/_known_hosts_real/known_hosts
@@ -6,3 +6,5 @@ jub,10.0.0.1
 kyl,100.0.0.2
 [10.10.0.3]:10022
 [blah]:1234
+fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555
+fe80::123:0xff:dead:beef%eth0
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 0b1a82f..8869de1 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -17,8 +17,8 @@ setup
 set test "Hosts should be put in COMPREPLY"
 set hosts [get_hosts]
     # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
-    # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3 and blah in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3
+    # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 and fe80::123:0xff:dead:beef%eth0 in ./fixtures/_known_hosts_real/known_hosts
+lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0
 set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
 assert_bash_list $hosts $cmd $test
 
@@ -29,8 +29,8 @@ sync_after_int
 set test "Hosts should have username prefix and colon suffix"
 set hosts [get_hosts]
     # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
-    # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3 and blah in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3
+    # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 and fe80::123:0xff:dead:beef%eth0 in ./fixtures/_known_hosts_real/known_hosts
+lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0
 set hosts [lsort -ascii $hosts]
 set expected {}
 foreach host $hosts {
@@ -103,8 +103,8 @@ set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
 assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
 set hosts [get_hosts_avahi]
     # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
-    # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3 and blah in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3
+    # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 and fe80::123:0xff:dead:beef%eth0 in ./fixtures/_known_hosts_real/known_hosts
+lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0
     # Call _known_hosts
 set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
 assert_bash_list $hosts $cmd $test

-- 
bash-completion



More information about the Bash-completion-commits mailing list