diff options
author | Aaron Peschel <aaron.peschel@gmail.com> | 2013-12-13 22:51:09 -0800 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2013-12-13 22:51:09 -0800 |
commit | 8ffba43be97e90be5753a90e3b5869450f108c79 (patch) | |
tree | 8b0348271e03bc42d5ceb6e48f9535a714f95e35 /Completion/Unix | |
parent | bcda34a0b39e2bca669c2ae1c6f203e175059a02 (diff) | |
download | zsh-8ffba43be97e90be5753a90e3b5869450f108c79.tar.gz zsh-8ffba43be97e90be5753a90e3b5869450f108c79.tar.xz zsh-8ffba43be97e90be5753a90e3b5869450f108c79.zip |
32103: parse host:port format in ssh known_hosts files.
Diffstat (limited to 'Completion/Unix')
-rw-r--r-- | Completion/Unix/Type/_hosts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Completion/Unix/Type/_hosts b/Completion/Unix/Type/_hosts index 499caede1..c3133dc68 100644 --- a/Completion/Unix/Type/_hosts +++ b/Completion/Unix/Type/_hosts @@ -41,9 +41,20 @@ if ! zstyle -a ":completion:${curcontext}:hosts" hosts _hosts; then for khostfile in $khostfiles; do if [[ -r $khostfile ]]; then - khosts=(${${(s:,:)${(j:,:)${(u)${(f)"$(<$khostfile)"}%%[ |#]*}}}:#*[\[\]]*}) + khosts=(${(s/,/j/,/u)${(f)"$(<$khostfile)"}%%[ |#]*}) + + # known_hosts syntax supports the host being in the form [hostname]:port + # The filter below extracts the hostname from lines using this format. + khosts=($(for host ($khosts); do + if [[ $host =~ "\[(.*)\]:\d*" ]]; then + echo $match + else + echo $host + fi + done)) + if [[ -z $useip ]]; then - khosts=(${${${khosts:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)}:#*[\[\]]*}) + khosts=(${${khosts:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)}) fi _cache_hosts+=($khosts) fi |