[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 6f921d563bfd750d17912ae71bd91b301d4300c4
Ville Skyttä
ville.skytta at iki.fi
Thu Nov 26 20:05:41 UTC 2009
The following commit has been merged in the master branch:
commit 6f921d563bfd750d17912ae71bd91b301d4300c4
Author: Ville Skyttä <ville.skytta at iki.fi>
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 [ ${#config[@]} -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' "${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]//\"/}")
+ 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' "${config[@]}" ) )
+ for i in "${tmpkh[@]}"; do
+ i=$( echo "${i//\"/}" )
+ [ -r "$i" ] && kh=( "${kh[@]}" "$i" )
done
IFS=$OIFS
fi
# Global known_hosts files
- [ -r "$global_kh" ] &&
- kh=( "${kh[@]}" "${global_kh[@]}" )
if [ -z "$configfile" ]; then
[ -r /etc/ssh/ssh_known_hosts ] &&
kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
@@ -1288,8 +1283,6 @@ _known_hosts_real()
fi
# User known_hosts files
- [ -r "$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