zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Damien Wyart <damien.wyart@free.fr>
Cc: zsh-workers@sunsite.dk
Subject: Re: Errors with ssh and rsync completion in zsh-beta (Debian unstable)
Date: Thu, 5 Jul 2007 19:20:08 +0100	[thread overview]
Message-ID: <20070705192008.6c79668e@news01.csr.com> (raw)
In-Reply-To: <20070705162157.GA3988@localhost.localdomain>

On Thu, 5 Jul 2007 18:21:57 +0200
Damien Wyart <damien.wyart@free.fr> wrote:
> I get error messages when completing in ssh or rsync commands :
> 
> ,----
> | dwyart@dalpdw2:~$ ssh dw
> | _combination:86: bad floating point constant
> | _combination:86: bad math expression: operator expected at `root'
> | dwyart@dalpdw2:~$ ssh dw@b
> | _combination:76: bad math expression: operator expected at `root'
> | _combination:86: bad floating point constant
> | dwyart@dalpdw2:~$ rsync -av dw@b
> | _combination:76: bad math expression: operator expected at `root'
> `----

Thanks for spotting this.  Here's what's happened.  _combination takes
arguments that may indicate with a suffix :<num> that the num'th match
should be used.  However, it's sloppy about testing for the suffix, and if
the suffix isn't present it uses the full expression.  This was the name of
an array variable ("hosts" in one of the cases).  In previous versions of
the shell, evaluating an array in math context substituted 0 so this went
unnoticed (it still wasn't the right thing to do, obviously).  However,
we've now fixed the syntax so that an array evaluated in math context does
what (I would think) you always expected it would.

The fix is to test for a number properly in _combination.

Index: Completion/Base/Utility/_combination
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_combination,v
retrieving revision 1.1
diff -u -r1.1 _combination
--- Completion/Base/Utility/_combination	2 Apr 2001 11:10:08 -0000	1.1
+++ Completion/Base/Utility/_combination	5 Jul 2007 18:17:00 -0000
@@ -72,13 +72,21 @@
 while [[ "$1" = *=* ]]; do
   tmp="${1%%\=*}"
   key="${tmp%:*}"
-  num="${${tmp##*:}:-1}"
+  if [[ $1 = *:* ]]; then
+    num=${tmp##*:}
+  else
+    num=1
+  fi
   pats[$keys[(in:num:)$key]]="${1#*\=}"
   shift
 done
 
 key="${1%:*}"
-num="${${1##*:}:-1}"
+if [[ $1 = *:* ]]; then
+  num=${1##*:}
+else
+  num=1
+fi
 shift
 
 if zstyle -a ":completion:${curcontext}:$tag" "$style" tmp; then


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


      parent reply	other threads:[~2007-07-05 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-05 16:21 Damien Wyart
2007-07-05 17:32 ` Clint Adams
2007-07-06 13:04   ` Damien Wyart
2007-07-05 18:20 ` Peter Stephenson [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=20070705192008.6c79668e@news01.csr.com \
    --to=pws@csr.com \
    --cc=damien.wyart@free.fr \
    --cc=zsh-workers@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).