zsh-workers
 help / color / mirror / code / Atom feed
* ZSH SSH completion with new Include directive in OpenSSH
@ 2017-05-25  9:51 Nikola Milojević
  2017-05-26  4:53 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Nikola Milojević @ 2017-05-25  9:51 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

Hi,

I've stumbled upon that ssh completion doesn't work with the new Include
directive in OpenSSH 7.3. That commands include ssh config files from the
custom folder you set.

Do you have it in a roadmap to fix that?

Thanks,

Nikola

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ZSH SSH completion with new Include directive in OpenSSH
  2017-05-25  9:51 ZSH SSH completion with new Include directive in OpenSSH Nikola Milojević
@ 2017-05-26  4:53 ` Bart Schaefer
  2017-05-26 10:53   ` Daniel Shahaf
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-05-26  4:53 UTC (permalink / raw)
  To: zsh-workers

On May 25,  9:51am, Nikola Milojevic wrote:
}
} I've stumbled upon that ssh completion doesn't work with the new Include
} directive in OpenSSH 7.3. That commands include ssh config files from the
} custom folder you set.
} 
} Do you have it in a roadmap to fix that?

I've forgotten again now why we have this:

  # If users-hosts matches, we shouldn't complete anything else.

My ~/.ssh/config is never read, period, because users-hosts always
returns something.

Nevertheless I suppose you're looking for something like the following
(the "Match" directive is unlikely ever to be interpreted):

diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 6763e24..cd106ad 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -680,17 +680,23 @@ _ssh_hosts () {
     config="$HOME/.ssh/config"
   fi
   if [[ -r $config ]]; then
-    local key hosts host
-    while IFS=$'=\t ' read -r key hosts; do
-      if [[ "$key" == (#i)host ]]; then
-         for host in ${(z)hosts}; do
-            case $host in
-            (*[*?]*) ;;
-            (*) config_hosts+=("$host") ;;
-            esac
-         done
-      fi
-    done < "$config"
+    local key line host
+    local -a lines=("${(@f)$(<"$config")}")
+    while (($#lines)); do
+      IFS=$'=\t ' read -r key line <<<"${lines[1]}"
+      case "$key" in
+      ((#i)include)
+        lines[1]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}");;
+      ((#i)host(|name))
+        for host in ${(z)line}; do
+          case $host in
+          (*[*?]*) ;;
+          (*) config_hosts+=("$host") ;;
+          esac
+        done; ;&
+      (*) shift lines;;
+      esac
+    done
     if (( ${#config_hosts} )); then
       _wanted hosts expl 'remote host name' \
         compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ZSH SSH completion with new Include directive in OpenSSH
  2017-05-26  4:53 ` Bart Schaefer
@ 2017-05-26 10:53   ` Daniel Shahaf
  2017-05-26 11:02     ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2017-05-26 10:53 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote on Thu, 25 May 2017 21:53 -0700:
> Nevertheless I suppose you're looking for something like the following
> (the "Match" directive is unlikely ever to be interpreted):

Note that we've already received patches for ssh_config(5) Include support,
such as 40688.  I think they were neither applied nor rejected, just pending.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ZSH SSH completion with new Include directive in OpenSSH
  2017-05-26 10:53   ` Daniel Shahaf
@ 2017-05-26 11:02     ` Peter Stephenson
  2017-05-27  0:03       ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2017-05-26 11:02 UTC (permalink / raw)
  To: zsh-workers

On Fri, 26 May 2017 10:53:26 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Bart Schaefer wrote on Thu, 25 May 2017 21:53 -0700:
> > Nevertheless I suppose you're looking for something like the following
> > (the "Match" directive is unlikely ever to be interpreted):
> 
> Note that we've already received patches for ssh_config(5) Include support,
> such as 40688.  I think they were neither applied nor rejected, just pending.

Could someone who thinks they know enough about ssh check and
apply them? Thanks.

(There is no magic "check and apply all pending patches" daemon round
here, unfortunately, and we've gone blue in the face asking for
volunteers for administrative help.)

pws


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ZSH SSH completion with new Include directive in OpenSSH
  2017-05-26 11:02     ` Peter Stephenson
@ 2017-05-27  0:03       ` Bart Schaefer
  2017-05-27  1:34         ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-05-27  0:03 UTC (permalink / raw)
  To: zsh-workers

On May 26, 12:02pm, Peter Stephenson wrote:
}
} > Note that we've already received patches for ssh_config(5) Include
} > support, such as 40688. I think they were neither applied nor
} > rejected, just pending.
} 
} Could someone who thinks they know enough about ssh check and
} apply them? Thanks.

The difference between 40688 and my 41156 seems to be that 40688 uses
a grep to try to extract all the Include out of ~/.ssh/config and then
run through all the files in a loop.  41156 on the other hand expands
the included files at the point where they appear in the original.

40688 won't necessarily process them in the right order, although that
probably doesn't matter, but I think it will miss out the case where
one of the included files itself includes another file.  41156 deals
with that case.

Also 41156 recognizes both "Host" and "HostName" lines, 40688 still
knows only about "Host".

Nevertheless it would be nice to have someone else look it over.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ZSH SSH completion with new Include directive in OpenSSH
  2017-05-27  0:03       ` Bart Schaefer
@ 2017-05-27  1:34         ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2017-05-27  1:34 UTC (permalink / raw)
  To: zsh-workers

On May 26,  5:03pm, Bart Schaefer wrote:
}
} The difference between 40688 and my 41156 seems to be

Sorry, all those references to 41156 should be 41159 -- there's something
wrong with the web archive linkage, it pulls up the wrong message when
clicking on the subject of this thread.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-27  1:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-25  9:51 ZSH SSH completion with new Include directive in OpenSSH Nikola Milojević
2017-05-26  4:53 ` Bart Schaefer
2017-05-26 10:53   ` Daniel Shahaf
2017-05-26 11:02     ` Peter Stephenson
2017-05-27  0:03       ` Bart Schaefer
2017-05-27  1:34         ` 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).