[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 56c12d5570699ecd4059379b64cc630832691ebe

Ville Skyttä ville.skytta at iki.fi
Sat Feb 5 10:14:48 UTC 2011


The following commit has been merged in the master branch:
commit 56c12d5570699ecd4059379b64cc630832691ebe
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Feb 5 12:14:42 2011 +0200

    Clean up some redundant code.

diff --git a/bash_completion b/bash_completion
index 0b5005e..b53091a 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1244,12 +1244,10 @@ _known_hosts_real()
         [ -r "$configfile" ] &&
         config=( "${config[@]}" "$configfile" )
     else
-        [ -r /etc/ssh/ssh_config ] &&
-        config=( "${config[@]}" "/etc/ssh/ssh_config" )
-        [ -r "${HOME}/.ssh/config" ] &&
-        config=( "${config[@]}" "${HOME}/.ssh/config" )
-        [ -r "${HOME}/.ssh2/config" ] &&
-        config=( "${config[@]}" "${HOME}/.ssh2/config" )
+        for i in /etc/ssh/ssh_config "${HOME}/.ssh/config" \
+            "${HOME}/.ssh2/config"; do
+            [ -r $i ] && config=( "${config[@]}" "$i" )
+        done
     fi
 
     # Known hosts files from configs
@@ -1271,28 +1269,16 @@ _known_hosts_real()
         IFS=$OIFS
     fi
 
-    # Global known_hosts files
-    if [ -z "$configfile" ]; then
-        [ -r /etc/ssh/ssh_known_hosts ] &&
-        kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
-        [ -r /etc/ssh/ssh_known_hosts2 ] &&
-        kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
-        [ -r /etc/known_hosts ] &&
-        kh=( "${kh[@]}" /etc/known_hosts )
-        [ -r /etc/known_hosts2 ] &&
-        kh=( "${kh[@]}" /etc/known_hosts2 )
-        [ -d /etc/ssh2/knownhosts ] &&
-        khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
-    fi
-
-    # User known_hosts files
     if [ -z "$configfile" ]; then
-        [ -r ~/.ssh/known_hosts ] &&
-        kh=( "${kh[@]}" ~/.ssh/known_hosts )
-        [ -r ~/.ssh/known_hosts2 ] &&
-        kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
-        [ -d ~/.ssh2/hostkeys ] &&
-        khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
+        # Global and user known_hosts files
+        for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \
+            /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \
+            ~/.ssh/known_hosts2; do
+            [ -r $i ] && kh=( "${kh[@]}" $i )
+        done
+        for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
+            [ -d $i ] && khd=( "${khd[@]}" $i/*pub )
+        done
     fi
 
     # If we have known_hosts files to use

-- 
bash-completion



More information about the Bash-completion-commits mailing list