diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-02-05 12:14:42 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-02-05 12:14:42 +0200 |
commit | 56c12d5570699ecd4059379b64cc630832691ebe (patch) | |
tree | 4280c5352ba7050e79adf42fe00f00d6f84ef28d | |
parent | 6aecdb5f4cf0fe8b44ee6a3a6442898141185711 (diff) | |
download | bash-completion-56c12d5570699ecd4059379b64cc630832691ebe.tar.gz |
Clean up some redundant code.
-rw-r--r-- | bash_completion | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/bash_completion b/bash_completion index 0b5005ee..b53091a5 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 |