Fix handling of known hosts files starting with ~.

https://bugzilla.redhat.com/show_bug.cgi?id=541423#c3

Done by adding the eval back.  The only thing that this breaks AFAIK
is handling of known hosts filenames that have more than one
consecutive space in them, but I couldn't figure out how to get both
to work and IMO support for files starting with ~ is much more
important.
This commit is contained in:
Ville Skyttä 2009-11-26 23:30:04 +02:00
parent 6f921d563b
commit 76de7c2984

View File

@ -1260,9 +1260,12 @@ _known_hosts_real()
local OIFS=$IFS IFS=$'\n'
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//\"/}" )
# TODO(?): try to make known hosts files with more than one consecutive
# spaces in their name work (watch out for ~ expansion
# breakage! Alioth#311595)
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=$( eval echo "$i" ) # expand ~
[ -r "$i" ] && kh=( "${kh[@]}" "$i" )
done
IFS=$OIFS