The following commit has been merged in the master branch:
commit 6f921d563bfd750d17912ae71bd91b301d4300c4
Author: Ville Skyttä <[email protected]>
Date: Thu Nov 26 21:53:02 2009 +0200
Fix reading rest of user/global known hosts files when the first one is not
readable.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c2
As a side effect, this simplifies things somewhat and grabs user and
global known hosts filenames from config files with one command
instead of doing one for each.
diff --git a/CHANGES b/CHANGES
index b4c8cb4..1b0328e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,7 +24,7 @@ bash-completion (2.x)
* Apply pine completion to alpine too.
* Remove many unnecessary short option completions where long ones exist.
* Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
- mysqladmin, service, and ssh completions.
+ mysqladmin, service, ssh, and general hostname completions.
* Add abook and wtf completion, based on work by Raphaël Droz.
* Add k3b and lftpget completion.
* Don't overwrite other host completions when completing from multiple
diff --git a/bash_completion b/bash_completion
index 8619676..9cee425 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1223,7 +1223,7 @@ _known_hosts()
_known_hosts_real()
{
local configfile flag prefix
- local cur curd awkcur user suffix aliases global_kh user_kh hosts i host
+ local cur curd awkcur user suffix aliases hosts i host
local -a kh khd config
local OPTIND=1
@@ -1258,22 +1258,17 @@ _known_hosts_real()
if [ ${#conf...@]} -gt 0 ]; then
local OIFS=$IFS IFS=$'\n'
- # 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' "${conf...@]}" ))
- for (( i=0; i < ${#global_...@]}; 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' "${conf...@]}" ))
- for (( i=0; i < ${#user_...@]}; i++ )); do
- user_kh[i]=$(echo "${user_kh[i]//\"/}")
+ local -a tmpkh
+ # expand paths (if present) to global and user known hosts files
+ tmpkh=( $( sed -ne 's/^[
\t]*\([Gg][Ll][Oo][Bb][Aa][Ll]\|[Uu][Ss][Ee][Rr]\)[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t
'"']*\(.*\)$/"\2"/p' "${conf...@]}" ) )
+ for i in "${tmp...@]}"; do
+ i=$( echo "${i//\"/}" )
+ [ -r "$i" ] && kh=( "${...@]}" "$i" )
done
IFS=$OIFS
fi
# Global known_hosts files
- [ -r "$global_kh" ] &&
- kh=( "${...@]}" "${global_...@]}" )
if [ -z "$configfile" ]; then
[ -r /etc/ssh/ssh_known_hosts ] &&
kh=( "${...@]}" /etc/ssh/ssh_known_hosts )
@@ -1288,8 +1283,6 @@ _known_hosts_real()
fi
# User known_hosts files
- [ -r "$user_kh" ] &&
- kh=( "${...@]}" "${user_...@]}" )
if [ -z "$configfile" ]; then
[ -r ~/.ssh/known_hosts ] &&
kh=( "${...@]}" ~/.ssh/known_hosts )
--
bash-completion
_______________________________________________
Bash-completion-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/bash-completion-commits