Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Parse Additional SSH known_hosts Syntax
- X-seq: zsh-workers 32102
- From: Aaron Peschel <aaron.peschel@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Parse Additional SSH known_hosts Syntax
- Date: Thu, 12 Dec 2013 15:52:17 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=2zhSn/y21eqf205rdsWp+Xy24CEheaYR3nHga2yRObI=; b=GeAuMYTEMgBuzBDuV5hBk0mvVWJ6QjIwJi+DZ7fkfjV87mFckGGQTBeInitZvghIn5 nIgAQKx7ODRWKD017TJzO793so+RXB2gcBXG25tLM6Ke50gybMX+UKdNMhqS8dyIqE63 GfJUGfYgFCTitYJ7fwM9u3qIK0fb3d700ofsDR92qJm3IZExTgMh5aIsTupE7WiKJqqe PCyx+bhSiX9eI/RdIia2Wa3+sG4gxeBN7DK9gDO7pZ6NH+gz5TI2jpXPvufJ0Pj9zRcH LfcsVf9PTA4gk9voK5Rq0q1lnxME64wgvoogYBoGV3feJNO3BVZurvCGLZtd46cKdd8v gIcQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hello,
I have created a patch for ZSH to support additional known_hosts
syntax. Feedback would be appreciated.
Thank you!
Aaron Peschel
-----
From 3d05d6f46ac89f1d91f6e7ab4981c2dc410c956a Mon Sep 17 00:00:00 2001
From: Aaron Peschel <apeschel@xxxxxxxxxxx>
Date: Thu, 12 Dec 2013 15:43:55 -0800
Subject: [PATCH 1/1] Parse Additional SSH known_hosts Syntax
ZSH does not currently support the full known_hosts syntax. The
known_hosts file supports lines starting with "[hostname]:post". ZSH
currently discards these lines, which breaks SSH auto-completion on
hosts using a non-standard SSH port. This patch adds support for this
syntax and allows auto-completion to work in this case.
---
Completion/Unix/Type/_hosts | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/Completion/Unix/Type/_hosts b/Completion/Unix/Type/_hosts
index 499caed..c3133dc 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
--
1.8.3.4 (Apple Git-47)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author