zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: hostname completion for ssh / scp
Date: Sat, 5 Nov 2016 13:29:53 -0700	[thread overview]
Message-ID: <161105132953.ZM17234@torch.brasslantern.com> (raw)
In-Reply-To: <581E2AE5.4040006@gmx.ch>

On Nov 5,  7:54pm, Fourhundred Thecat wrote:
} Subject: Re: hostname completion for ssh / scp
}
} > On 2016-11-05 18:24, Bart Schaefer wrote:
} > Well, yes.  The syntax of the /etc/hosts file is first an IP and then
} > a hostname.  Somebody will possibly correct me, but I don't recall
} > any valid use of /etc/hosts that has lines of host names without IPs.
} 
} Not true. IP address is not mandatory in /etc/hosts.

/etc/hosts is a file read by the DNS resolver library to look up IPs
for hosts that either aren't found in DNS, or that locally need to
use a different IP than the one found by a network DNS lookup.  It
is not there for purposes of configuring completions in the shell,
and lines that don't have an IP address are useless for the intended
purpose of the file.

Read "man 5 hosts".  Bash might let you use it the way you say by way
of a non-strict parse of the contents, but that doesn't make it right.

} > However, ~/.ssh/config will be skipped if the users-hosts tag finds
} > any matching hosts
} 
} yes that is correct.
} But this is a terrible feature. The completion jumps to first matching
} hostname, completely ignoring other matching hostnames.

This goes way back to 2007, users/11333 and the thread leading up to it.

The intention is that if the user has the users-hosts style configured
for the my-accounts tag and gets a match from it, then ~/.ssh/config
should not be consulted.

However, because _combination is used by _ssh_hosts to also call the
completion for hosts, the users-hosts lookup can succeed even if the
users-hosts style is unset.  I don't think that was an expected effect.
However, I don't know the best way to address it.

I expected to be able to work around this by:

zstyle -e ':completion:*:(ssh|scp):*:my-accounts' users-hosts 'return 1'

and indeed that bypasses the call to _hosts, but the return value from
_combination is not 1, so ~/.ssh/config is still not examined.  So
that's another bug to file.


  reply	other threads:[~2016-11-05 20:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03 19:11 Fourhundred Thecat
2016-11-05  4:42 ` Bart Schaefer
2016-11-05  8:55   ` Fourhundred Thecat
2016-11-05 17:24     ` Bart Schaefer
2016-11-05 18:54       ` Fourhundred Thecat
2016-11-05 20:29         ` Bart Schaefer [this message]
2016-11-05 20:54           ` Fourhundred Thecat
2016-11-05 22:53           ` Bart Schaefer
2016-11-06  8:49             ` Fourhundred Thecat
2016-11-06 17:41               ` Bart Schaefer
     [not found]       ` <581E2AE5.4040006__46101.1380576112$1478372966$gmane$org@gmx.ch>
2016-11-05 20:31         ` Daniel Shahaf
2016-11-05 20:50           ` Fourhundred Thecat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161105132953.ZM17234@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).