[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-46-g68e9a8e

Freddy Vulto fvulto at gmail.com
Sun Mar 27 21:13:04 UTC 2011


The following commit has been merged in the master branch:
commit 68e9a8e6eb8d92ae67a694efd6ffcd986e8f7f5b
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Sun Mar 27 23:12:14 2011 +0200

    (testsuite) Add -unsorted option to _get_hosts()
    _known_hosts_real tests were failing after commit 81794a9:
    
       FAIL: Hosts should be put in COMPREPLY
       FAIL: Hosts should have username prefix and colon suffix
    
    This is because tcl's get_hosts() is now doing a unique sort, but bash
    _known_hosts_real() IS returning duplicates relying on bash's compgen/complete
    to remove the duplicates).  Fixed by calling _get_hosts -unsorted.

diff --git a/test/lib/library.exp b/test/lib/library.exp
index 491da21..9cd77c9 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -633,10 +633,17 @@ proc get_known_hosts {{cword ''}} {
 
 
 # Get hostnames
+# @param list $args  Options:
+#                    --unsorted  Do not sort unique.  Default is sort unique.
 # @return list  Hostnames
 # @see get_known_hosts()
-proc get_hosts {} {
-    set hosts [exec bash -c "compgen -A hostname | sort -u"]
+proc get_hosts {{args {}}} {
+    array set arg [::cmdline::getoptions args {
+        {unsorted   "do not sort unique"}
+    }]
+    set sort "| sort -u"
+    if {$arg(unsorted)} {set sort ""}
+    set hosts [exec bash -c "compgen -A hostname $sort"]
     # NOTE: Circumventing var `avahi_hosts' and appending directly to `hosts'
     #       causes an empty element to be inserted in `hosts'.
     #       -- FVu, Fri Jul 17 23:11:46 CEST 2009
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 604b2d5..0e381fa 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -19,7 +19,7 @@ setup
 
 
 set test "Hosts should be put in COMPREPLY"
-set hosts [get_hosts]
+set hosts [get_hosts -unsorted]
     # 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, blah, and bunch of IPv6 test cases 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 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
@@ -31,7 +31,7 @@ sync_after_int
 
 
 set test "Hosts should have username prefix and colon suffix"
-set hosts [get_hosts]
+set hosts [get_hosts -unsorted]
     # 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, blah, and bunch of IPv6 test cases 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 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
@@ -49,7 +49,7 @@ sync_after_int
 
 
 set test "Files containing consecutive spaces should work"
-set hosts [get_hosts]
+set hosts [get_hosts -unsorted]
 set hosts_orig $hosts
     # Hosts `gee' and `hus' are defined in `./fixtures/_known_hosts_real/spaced  conf'
     # Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
@@ -77,7 +77,7 @@ sync_after_int
 
 
 set test "Files starting with tilde (~) should work"
-set hosts [get_hosts]
+set hosts [get_hosts -unsorted]
     # Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
     # Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3
 lappend hosts two three

-- 
bash-completion



More information about the Bash-completion-commits mailing list