zsh-users
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayned@users.sourceforge.net>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-users@sunsite.dk
Subject: Re: Mysterious completion of variables
Date: Fri, 18 Nov 2005 09:38:57 -0800	[thread overview]
Message-ID: <20051118173857.GA19215@dot.blorf.net> (raw)
In-Reply-To: <20051118114705.0bd95c76.pws@csr.com>

On Fri, Nov 18, 2005 at 11:47:05AM +0000, Peter Stephenson wrote:
> +      if [[ "$key" == (#i)host ]]; then
> +         config_hosts+=("$host")
> +      fi

There's two problems with this for general use (as pointed out by Ian
himself):  it puts multiple hostnames into a single completion item, and
it includes wild-carded items as hostnames.  I patched the function like
this:

--- Completion/Unix/Command/_ssh	18 Nov 2005 14:53:44 -0000	1.25
+++ Completion/Unix/Command/_ssh	18 Nov 2005 17:22:39 -0000
@@ -320,10 +320,15 @@ _ssh_hosts () {
       ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
   fi
   if [[ -r "$HOME/.ssh/config" ]]; then
-    local IFS=$'\t ' key host
-    while read key host; do
+    local IFS=$'\t ' key hosts host
+    while read key hosts; do
       if [[ "$key" == (#i)host ]]; then
-	 config_hosts+=("$host")
+	 for host in ${(z)hosts}; do
+	    case $host in
+	    (*[*?]*) ;;
+	    (*) config_hosts+=("$host") ;;
+	    esac
+	 done
       fi
     done < "$HOME/.ssh/config"
     if (( ${#config_hosts} )); then

There may well be a non-looping way to do that, so feel free to
enlighten me if there is.

..wayne..


      parent reply	other threads:[~2005-11-18 17:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 20:36 Ian Langworth
2005-11-18 10:21 ` Peter Stephenson
2005-11-18 11:32 ` Hannu Koivisto
2005-11-18 11:47   ` Peter Stephenson
2005-11-18 14:20     ` Ian Langworth
2005-11-18 17:38     ` Wayne Davison [this message]

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=20051118173857.GA19215@dot.blorf.net \
    --to=wayned@users.sourceforge.net \
    --cc=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /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).