[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 65c2ea97aeee309eb1b4f25241885550d2f7805e

Freddy Vulto fvulto at gmail.com
Thu Apr 16 21:26:30 UTC 2009


The following commit has been merged in the master branch:
commit 65c2ea97aeee309eb1b4f25241885550d2f7805e
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Thu Apr 16 23:25:22 2009 +0200

    Patched _known_hosts() to support multiple {Global,User}KnownHosts in
    SSH config files, thanks to Thomas Nilsson.
    (Alioth: #311595) (Debian: #524190)

diff --git a/CHANGES b/CHANGES
index bf93241..d5748e9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -58,6 +58,10 @@ bash-completion (1.x)
   [ Philipp Weis ]
   * Add .dvi.{gz,bz2} completion for evince/okular (Debian: #522656)
 
+  [ Freddy Vulto ]
+  * Patched _known_hosts() to support multiple {Global,User}KnownHosts in SSH
+    config files, thanks to Thomas Nilsson (Alioth: #311595) (Debian: #524190)
+
  -- David Paleino <d.paleino at gmail.com>  Wed, 25 Mar 2009 23:18:24 +0100
 
 bash-completion (1.0)
diff --git a/bash_completion b/bash_completion
index 360c55c..2527d17 100644
--- a/bash_completion
+++ b/bash_completion
@@ -2700,6 +2700,7 @@ _known_hosts()
 	local configfile
 	local cur curd ocur user suffix aliases global_kh user_kh hosts i host
 	local -a kh khd config
+	local IFS=$'\n'
 
 	COMPREPLY=()
 	cur=`_get_cword`
@@ -2731,15 +2732,21 @@ _known_hosts()
 	fi
 
 	if [ ${#config[@]} -gt 0 ]; then
-	    # expand path (if present) to global known hosts file
-	    global_kh=$( echo $( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
-	    # expand path (if present) to user known hosts file
-	    user_kh=$( echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
+		# expand path (if present) to global known hosts file
+		global_kh=($( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ))
+		for (( i=0; i < ${#global_kh[@]}; i++ )); do
+			global_kh[i]=$(echo "${global_kh[i]//\"/}")
+		done
+		# expand path (if present) to user known hosts file
+		user_kh=($( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ))
+		for (( i=0; i < ${#user_kh[@]}; i++ )); do
+			user_kh[i]=$(echo "${user_kh[i]//\"/}")
+		done
 	fi
 
 	# Global known_hosts files
 	[ -r "$global_kh" ] &&
-		kh=( "${kh[@]}" "$global_kh" )
+		kh=( "${kh[@]}" "${global_kh[@]}" )
 	if [ -z "$configfile" ]; then
 		[ -r /etc/ssh/ssh_known_hosts ] &&
 		  kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
@@ -2755,7 +2762,7 @@ _known_hosts()
 
 	# User known_hosts files
 	[ -r "$user_kh" ] &&
-		kh=( "${kh[@]}" "$user_kh" )
+		kh=( "${kh[@]}" "${user_kh[@]}" )
 	if [ -z "$configfile" ]; then
 		[ -r ~/.ssh/known_hosts ] &&
 		  kh=( "${kh[@]}" ~/.ssh/known_hosts )

-- 
bash-completion



More information about the Bash-completion-commits mailing list