Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autocompletion with ssh and .ssh/config

On Sun, 18 Jul 2010 10:51:32 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 18 July 2010 07:21, Benjamin R. Haskell <zsh@xxxxxxxxxx> wrote:
> > On Sun, 18 Jul 2010, David Duponchel wrote:
> >> I have some hosts defined in my .ssh/config file. Example :
> >> Host bar
> >>     HostName
> >>
> >> Host baz
> >>     HostName
> >>
> >> When I type ssh <tab>, only my users and hosts in /etc/hosts are
> >> displayed (my .ssh/config is ignored).
> >> With ssh ba<tab> the autocompletion is correctly done and propose bar
> >> and baz.
> >
> > Host from ~/.ssh/config aren't proposed until hosts found from other
> > methods are exhausted.  The biggest reason that seems wrong (IMO) is
> > that 'other methods' includes ~/.ssh/known_hosts.  So, a host I've never
> > ssh'ed to won't be offered until I've ssh'ed to it.
> Here's the commit that introduced the &&returns,
> http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=commitdiff;h=7072c10ae223e24f601b3

... which contains little useful information but at least refers to where
the information is.  The correct reference is zsh-users/11333:


This fixed a problem that user@... completed machines that weren't
associated with that username even though the association is explicit.

The problem seems to be that user completion is being assumed even if it
hasn't happened, i.e. user@host completion is treated as succesful even
if there's no user@ bit.

The fix would be to separate these cases, i.e. ensure the return only
happens if a user was actually matched.  Simply removing the returns
would reintroduce the user-host completion bug.  I haven't probed any
deeper, but presumably _combination isn't up to the job on its own, and
it'll need an extra test somewhere.  Examination suggests the problem's
probably in the second branch, where there's no existing "@".  However,
I can't see offhand what the command is trying to do.

Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

Messages sorted by: Reverse Date, Date, Thread, Author