mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
32103: parse host:port format in ssh known_hosts files.
This commit is contained in:
parent
bcda34a0b3
commit
8ffba43be9
2 changed files with 18 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2013-12-13 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* Aaron Peschel: 32103: Completion/Unix/Type/_hosts: parse
|
||||
host:port format in ssh known_hosts files.
|
||||
|
||||
2013-12-10 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 32099: Src/init.c: fix pointer declaration to avoid compile
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue