summaryrefslogtreecommitdiff
path: root/bash_completion
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2009-12-13 11:41:55 +0200
committerVille Skyttä <ville.skytta@iki.fi>2009-12-13 11:41:55 +0200
commit5d691d48269e14433aec7e4482b3215ad7e24a14 (patch)
tree326597d02e061e7e560816608bd8ea1f761d5c5a /bash_completion
parenta358902e90d3acba98ac45a48cdd1d37baad3a04 (diff)
downloadbash-completion-5d691d48269e14433aec7e4482b3215ad7e24a14.tar.gz
Complete aliases also when there are no known hosts files (RedHat: #546905).
Diffstat (limited to 'bash_completion')
-rw-r--r--bash_completion14
1 files changed, 8 insertions, 6 deletions
diff --git a/bash_completion b/bash_completion
index 66fff101..5d8fa221 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1302,7 +1302,7 @@ _known_hosts_real()
fi
# If we have known_hosts files to use
- if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 || -n "$configfile" ]]; then
+ if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then
# Escape slashes and dots in paths for awk
awkcur=${cur//\//\\\/}
awkcur=${awkcur//\./\\\.}
@@ -1345,11 +1345,6 @@ _known_hosts_real()
fi
done
fi
- # append any available aliases from config files
- if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
- local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$hosts" -- "$cur" ) )
- fi
# apply suffix and prefix
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
@@ -1357,6 +1352,13 @@ _known_hosts_real()
done
fi
+ # append any available aliases from config files
+ if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
+ local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
+ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -P "$prefix$user" \
+ -S "$suffix" -W "$hosts" -- "$cur" ) )
+ fi
+
# Add hosts reported by avahi-browse, if it's available.
# The original call to avahi-browse also had "-k", to avoid lookups into
# avahi's services DB. We don't need the name of the service, and if it