summaryrefslogtreecommitdiff
path: root/bash_completion
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-12-05 21:58:04 +0200
committerVille Skyttä <ville.skytta@iki.fi>2011-12-05 21:58:04 +0200
commit17c9722733a3e50f7b5113ca99fba9424b078274 (patch)
tree0c981d5b0424c48fdb884f723ebfc723200eb026 /bash_completion
parentda4956af1fda85d80c75f89c13814cd57877c0bd (diff)
downloadbash-completion-17c9722733a3e50f7b5113ca99fba9424b078274.tar.gz
_known_hosts_real: Support > 1 files per *KnownHostsFile line (Debian: #650514).
Diffstat (limited to 'bash_completion')
-rw-r--r--bash_completion21
1 files changed, 14 insertions, 7 deletions
diff --git a/bash_completion b/bash_completion
index 03e31d4f..835146f2 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1425,21 +1425,28 @@ _known_hosts_real()
# Known hosts files from configs
if [[ ${#config[@]} -gt 0 ]]; then
- local OIFS=$IFS IFS=$'\n'
+ local OIFS=$IFS IFS=$'\n' j
local -a tmpkh
# expand paths (if present) to global and user known hosts files
# 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=( $( awk 'sub("^[ \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]+", "") { print $0 }' "${config[@]}" | sort -u ) )
+ IFS=$OIFS
for i in "${tmpkh[@]}"; do
- # Remove possible quotes
- i=${i//\"}
- # Eval/expand possible `~' or `~user'
- __expand_tilde_by_ref i
- [[ -r $i ]] && kh+=( "$i" )
+ # First deal with quoted entries...
+ while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do
+ i=${BASH_REMATCH[1]}${BASH_REMATCH[3]}
+ j=${BASH_REMATCH[2]}
+ __expand_tilde_by_ref j # Eval/expand possible `~' or `~user'
+ [[ -r $j ]] && kh+=( "$j" )
+ done
+ # ...and then the rest.
+ for j in $i; do
+ __expand_tilde_by_ref j # Eval/expand possible `~' or `~user'
+ [[ -r $j ]] && kh+=( "$j" )
+ done
done
- IFS=$OIFS
fi
if [[ -z $configfile ]]; then