From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13497 invoked from network); 18 Nov 2005 17:39:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Nov 2005 17:39:18 -0000 Received: (qmail 72550 invoked from network); 18 Nov 2005 17:39:09 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Nov 2005 17:39:09 -0000 Received: (qmail 14559 invoked by alias); 18 Nov 2005 17:39:00 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9690 Received: (qmail 14550 invoked from network); 18 Nov 2005 17:39:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 Nov 2005 17:39:00 -0000 Received: (qmail 71446 invoked from network); 18 Nov 2005 17:39:00 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 18 Nov 2005 17:38:59 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id 176A8A143; Fri, 18 Nov 2005 09:38:57 -0800 (PST) Date: Fri, 18 Nov 2005 09:38:57 -0800 From: Wayne Davison To: Peter Stephenson Cc: zsh-users@sunsite.dk Subject: Re: Mysterious completion of variables Message-ID: <20051118173857.GA19215@dot.blorf.net> References: <87psoynqcv.fsf@trews52.bothi.fi> <20051118114705.0bd95c76.pws@csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051118114705.0bd95c76.pws@csr.com> User-Agent: Mutt/1.5.9i 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..