zsh-workers
 help / color / mirror / code / Atom feed
* Errors with ssh and rsync completion in zsh-beta (Debian unstable)
@ 2007-07-05 16:21 Damien Wyart
  2007-07-05 17:32 ` Clint Adams
  2007-07-05 18:20 ` Peter Stephenson
  0 siblings, 2 replies; 4+ messages in thread
From: Damien Wyart @ 2007-07-05 16:21 UTC (permalink / raw)
  To: zsh-workers

Hello,

Playing a bit with completion, I came into the following problem. Having 
this kind of settings in .zshrc (simplified to get a minimal example) :

,----
| my_accounts=(
|     dw@myhost.dnsalias.net
|     root@10.4.8.3
| )
| 
| hosts=(
|     myhost.dnsalias.net
|     10.4.8.3
| )
| 
| users=(
|     dw
|     dwyart
|     root
| )
| 
| zstyle ':completion:*' hosts $hosts
| zstyle ':completion:*' users $users
| zstyle ':completion:*:my-accounts' users-hosts $my_accounts
`----

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'
`----


This behaviour is only present in zsh-beta from Debian unstable (version
4.3.4-dev-0+20070701-1), *not* in zsh (version 4.3.4-10, same distro).


Thanks in advance for hints/comments. Please keep me on Cc as I am not
on the list.


Best,

-- 
Damien Wyart


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Errors with ssh and rsync completion in zsh-beta (Debian unstable)
  2007-07-05 16:21 Errors with ssh and rsync completion in zsh-beta (Debian unstable) Damien Wyart
@ 2007-07-05 17:32 ` Clint Adams
  2007-07-06 13:04   ` Damien Wyart
  2007-07-05 18:20 ` Peter Stephenson
  1 sibling, 1 reply; 4+ messages in thread
From: Clint Adams @ 2007-07-05 17:32 UTC (permalink / raw)
  To: Damien Wyart; +Cc: zsh-workers

On Thu, Jul 05, 2007 at 06:21:57PM +0200, Damien Wyart wrote:
> Playing a bit with completion, I came into the following problem. Having 
> this kind of settings in .zshrc (simplified to get a minimal example) :

You can further simplify that to

users=(dw dwyart root)
zstyle ':completion:*' users $users
autoload -U compinit
compinit

and then..

+_ssh_hosts:7> _combination -s '[:@]' my-accounts users-hosts 'users=dw' hosts -J -default-
+_combination:53> local sep tag style keys pats key num tmp
+_combination:55> [[ -s == -s ]]
+_combination:56> sep='[:@]'
+_combination:57> shift 2
+_combination:65> tag=my-accounts
+_combination:66> style=users-hosts
+_combination:67> shift 2
+_combination:69> keys=( users hosts )
+_combination:70> pats=( '*' '*' )
+_combination:72> [[ 'users=dw' == '*=*' ]]
+_combination:73> tmp=users
+_combination:74> key=users
+_combination:75> num=users
_combination:76: bad math expression: operator expected at `dwyart roo...'
+_combination:76> pats[$keys[(in:num:)$key]]=dw
+_combination:77> shift


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Errors with ssh and rsync completion in zsh-beta (Debian unstable)
  2007-07-05 16:21 Errors with ssh and rsync completion in zsh-beta (Debian unstable) Damien Wyart
  2007-07-05 17:32 ` Clint Adams
@ 2007-07-05 18:20 ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2007-07-05 18:20 UTC (permalink / raw)
  To: Damien Wyart; +Cc: zsh-workers

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Errors with ssh and rsync completion in zsh-beta (Debian unstable)
  2007-07-05 17:32 ` Clint Adams
@ 2007-07-06 13:04   ` Damien Wyart
  0 siblings, 0 replies; 4+ messages in thread
From: Damien Wyart @ 2007-07-06 13:04 UTC (permalink / raw)
  To: zsh-workers

* Clint Adams <clint@zsh.org> [070705 19:32]:
> You can further simplify that to

> users=(dw dwyart root)
> zstyle ':completion:*' users $users
> autoload -U compinit
> compinit

> and then..
> [...]

Thanks for your explanations. I am not really a completion guru...

-- 
Damien Wyart


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-06 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-05 16:21 Errors with ssh and rsync completion in zsh-beta (Debian unstable) Damien Wyart
2007-07-05 17:32 ` Clint Adams
2007-07-06 13:04   ` Damien Wyart
2007-07-05 18:20 ` Peter Stephenson

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).