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

Ville Skyttä ville.skytta at iki.fi
Mon Oct 25 18:48:27 UTC 2010


The following commit has been merged in the master branch:
commit 7d45595493e1f830a3ddbdff845f05ce5a0bc696
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Oct 25 21:39:00 2010 +0300

    Complete known hosts from avahi-browse only if $COMP_KNOWN_HOSTS_WITH_AVAHI is non-empty.
    
    This effectively turns off avahi-browse by default; doing it by
    default is not worth it compared to the number of various (mostly
    slowness) problems it has caused people, for example Alioth #312691
    and RedHat #630326.
    
    Mandriva has applied a similar patch for some time already, although
    their environment variable name was different ($COMP_AVAHI_BROWSE).

diff --git a/CHANGES b/CHANGES
index 5f34ce4..7815f90 100644
--- a/CHANGES
+++ b/CHANGES
@@ -30,6 +30,8 @@ bash-completion (2.x)
     (Alioth: #312770).
   * Add /etc/ethers to MAC address completion sources.
   * Add *.gem to tar completions.
+  * Complete known hosts from avahi-browse only if $COMP_KNOWN_HOSTS_WITH_AVAHI
+    is non-empty (Alioth: #312691, RedHat: #630326).
 
   [ Freddy Vulto ]
   * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)
diff --git a/bash_completion b/bash_completion
index 0de5872..45e7612 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1153,7 +1153,8 @@ _known_hosts()
 
 # Helper function for completing _known_hosts.
 # This function performs host completion based on ssh's config and known_hosts
-# files, as well as hostnames reported by avahi-browse.  Also hosts from
+# files, as well as hostnames reported by avahi-browse if
+# COMP_KNOWN_HOSTS_WITH_AVAHI is set to a non-empty value.  Also hosts from
 # HOSTFILE (compgen -A hostname) are added, unless
 # COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value.
 # Usage: _known_hosts_real [OPTIONS] CWORD
@@ -1298,12 +1299,14 @@ _known_hosts_real()
             -S "$suffix" -W "$hosts" -- "$cur" ) )
     fi
 
-    # Add hosts reported by avahi-browse, if it's available.
-    # The original call to avahi-browse also had "-k", to avoid lookups into
-    # avahi's services DB. We don't need the name of the service, and if it
-    # contains ";", it may mistify the result. But on Gentoo (at least),
-    # -k isn't available (even if mentioned in the manpage), so...
-    if type avahi-browse >&/dev/null; then
+    # Add hosts reported by avahi-browse, if desired and it's available.
+    if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && \
+        type avahi-browse &>/dev/null; then
+        # The original call to avahi-browse also had "-k", to avoid lookups
+        # into avahi's services DB. We don't need the name of the service, and
+        # if it contains ";", it may mistify the result. But on Gentoo (at
+        # least), -k wasn't available (even if mentioned in the manpage) some
+        # time ago, so...
         COMPREPLY=( "${COMPREPLY[@]}" $( \
             compgen -P "$prefix$user" -S "$suffix" -W \
             "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
diff --git a/doc/bash_completion.txt b/doc/bash_completion.txt
index c7e7a2b..b10d674 100644
--- a/doc/bash_completion.txt
+++ b/doc/bash_completion.txt
@@ -19,7 +19,7 @@ Environment variables
 
 
 *COMP_KNOWN_HOSTS_WITH_HOSTFILE*::
-    If set and not null (default), known_hosts completion will complement
+    If set and not null (default), known hosts completion will complement
     hostnames from ssh's known_hosts_files with hostnames taken from the file
     specified by the HOSTFILE shell variable (compgen -A hostname). If null,
     known_hosts completion will omit hostnames from HOSTFILE.  Omitting
@@ -27,6 +27,12 @@ Environment variables
     local web development or ad-blocking.
 
 
+*COMP_KNOWN_HOSTS_WITH_AVAHI*::
+    If set and not null, known hosts completion will try to use `avahi-browse`
+    for additional completions.  This may be a slow operation in some setups.
+    Default is unset.
+
+
 *COMP_TAR_INTERNAL_PATHS*::
     If set and not null *before* sourcing bash_completion, `tar` completion
     will do correct path completion for tar file contents.  If unset or null,

-- 
bash-completion



More information about the Bash-completion-commits mailing list