* [PATCH] Parse Additional SSH known_hosts Syntax
@ 2013-12-12 23:52 Aaron Peschel
2013-12-12 23:55 ` Aaron Peschel
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Peschel @ 2013-12-12 23:52 UTC (permalink / raw)
To: zsh-workers
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@zendesk.com>
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Parse Additional SSH known_hosts Syntax
2013-12-12 23:52 [PATCH] Parse Additional SSH known_hosts Syntax Aaron Peschel
@ 2013-12-12 23:55 ` Aaron Peschel
2013-12-20 20:04 ` Aaron Peschel
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Peschel @ 2013-12-12 23:55 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 2225 bytes --]
Hello,
The patch got corrupted in the email. I have attached the patch here instead.
--Aaron
On Thu, Dec 12, 2013 at 3:52 PM, Aaron Peschel <aaron.peschel@gmail.com> wrote:
> 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@zendesk.com>
> 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)
[-- Attachment #2: 0001-Parse-Additional-SSH-known_hosts-Syntax.patch --]
[-- Type: application/octet-stream, Size: 1793 bytes --]
From 3d05d6f46ac89f1d91f6e7ab4981c2dc410c956a Mon Sep 17 00:00:00 2001
From: Aaron Peschel <apeschel@zendesk.com>
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Parse Additional SSH known_hosts Syntax
2013-12-12 23:55 ` Aaron Peschel
@ 2013-12-20 20:04 ` Aaron Peschel
2013-12-20 20:31 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Aaron Peschel @ 2013-12-20 20:04 UTC (permalink / raw)
To: zsh-workers
Hello,
I am new to this project, what is the proper etiquette for getting
some attention on this list?
-Aaron
On Thu, Dec 12, 2013 at 3:55 PM, Aaron Peschel <aaron.peschel@gmail.com> wrote:
> Hello,
>
> The patch got corrupted in the email. I have attached the patch here instead.
>
> --Aaron
>
> On Thu, Dec 12, 2013 at 3:52 PM, Aaron Peschel <aaron.peschel@gmail.com> wrote:
>> 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@zendesk.com>
>> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Parse Additional SSH known_hosts Syntax
2013-12-20 20:04 ` Aaron Peschel
@ 2013-12-20 20:31 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2013-12-20 20:31 UTC (permalink / raw)
To: Aaron Peschel, zsh-workers
On Dec 20, 12:04pm, Aaron Peschel wrote:
}
} I am new to this project, what is the proper etiquette for getting
} some attention on this list?
Sorry about that. Probably just a case of everyone assuming that someone
else would pick this up.
One problem:
zsh: failed to load module: zsh/regex
zsh: -regex-match not available for regex
The test will need to be adjusted to not require the =~ operator, and it
should probably declare as local the match variables that will be set by
the backreference operation.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-20 20:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-12 23:52 [PATCH] Parse Additional SSH known_hosts Syntax Aaron Peschel
2013-12-12 23:55 ` Aaron Peschel
2013-12-20 20:04 ` Aaron Peschel
2013-12-20 20:31 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).