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

Freddy Vulto fvulto at gmail.com
Mon Aug 24 20:38:42 UTC 2009


The following commit has been merged in the master branch:
commit 9af88e6bd44c26b574869bb9f7ffb52fae7fd2fe
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Tue Aug 18 21:28:43 2009 +0200

    Fix unit test _known_hosts_real
    Test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE" now
    includes hosts reported by avahi.

diff --git a/test/lib/library.exp b/test/lib/library.exp
index 3299ccb..b663d3f 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -274,13 +274,10 @@ proc assert_exec {cmd {stdout ''} {test ''}} {
 # @return list  Hostnames
 proc get_hosts {} {
     set hosts [exec bash -c "compgen -A hostname"]
-    # NOTE: Circumenventing `avahi_host' and appending directly to `hosts'
+    # 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
-    set avahi_hosts [exec bash -c {
-        type avahi-browse >&/dev/null && [ -n "$(pidof avahi-daemon)" ]
-            avahi-browse -cpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
-    }]
+    set avahi_hosts [get_hosts_avahi]
     if {[llength $avahi_hosts] > 0} {
         lappend hosts $avahi_hosts
     }; # if
@@ -288,6 +285,17 @@ proc get_hosts {} {
 }; # get_hosts()
 
 
+# Get hostnames according to avahi
+# @return list  Hostnames
+proc get_hosts_avahi {} {
+    set hosts [exec bash -c {
+        type avahi-browse >&/dev/null && [ -n "$(pidof avahi-daemon)" ]
+            avahi-browse -cpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
+    }]
+    return $hosts
+}; # get_hosts_avahi()
+
+
 # Get signals
 # This function is written in analogy to the bash function `_signals()' in
 # `bash_completion'.
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 71966d5..94fc67e 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -82,7 +82,7 @@ sync_after_int
 
 set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
 assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
-set hosts {}
+set hosts [get_hosts_avahi]
     # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
     # Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts_real/known_hosts
 lappend hosts doo gee hus ike jar

-- 
bash-completion



More information about the Bash-completion-commits mailing list