zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _rsync - better rsync:// URL support and other fixes
@ 2005-03-26 21:36 Andrey Borzenkov
  2005-03-29 11:00 ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Borzenkov @ 2005-03-26 21:36 UTC (permalink / raw)
  To: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

- - add rsync:// support
- - strip server banner from output (let's hope it is consistent across servers)
- - fix modules completion (it interpreted whole line as description)

it still does not grok rsync://user@server:port/ nor does it support RSYNC_RSH 
or -e (-rsh) options. Probably it should, at least the latter means rsync is 
using rsh not rsync server irrespectively of URL form.

Absolutely ugly "compadd -S/ rsync:/" is the only way I know to add word with 
two slashes without adding blank. Oliver, do you have any idea (the same 
problem I had in _urpmi too).

Oh, and I noticed that I never actually get `Host for "$user"' prompt.

- -andrey

Index: Completion/Unix/Command/_rsync
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_rsync,v
retrieving revision 1.19
diff -u -p -r1.19 _rsync
- --- Completion/Unix/Command/_rsync      11 Mar 2005 19:24:35 -0000      1.19
+++ Completion/Unix/Command/_rsync      26 Mar 2005 21:33:34 -0000
@@ -1,11 +1,32 @@
 #compdef rsync

+_rsync_user_or_host() {
+  local suf=$1 rsync
+  shift
+
+  if compset -P 1 '*@'; then
+    local user=${PREFIX%%@*}
+
+    _wanted -C user-at hosts expl "host for $user" \
+       _combination -s '[:@]' "${tag}" users-hosts users="$user" hosts -S 
"$suf" "$@" -
+  elif compset -S '@*'; then
+      _wanted users expl "user" \
+         _combination -s '[:@]' "${tag}" users-hosts users -q "$@" -
+  else
+    [[ $words[CURRENT] = rsync://* ]] || rsync='rsync:rsync: compadd -S/ 
rsync:/'
+    _alternative \
+      'users:user:_users -S @' \
+      "hosts:host:_hosts -S '$suf'" \
+      $rsync
+  fi
+}
+
 _rsync_remote_files() {
 local expl remfiles remdispf remdispd remmodules suf ret=1 tag=accounts

- -if compset -P '*::*/'; then
+if compset -P '*::*/' || compset -P 'rsync://*/*/'; then

- -  remfiles=(${(f)"$(_call_program files rsync ${words[CURRENT]%/*}/)"})
+  remfiles=(${${(f)"$(_call_program files rsync 
${words[CURRENT]%/*}/)"}:#[   ]*})

   remdispf=(${remfiles:#d*})
   remdispd=(${(M)remfiles:#d*})
@@ -16,14 +37,22 @@ if compset -P '*::*/'; then
   _wanted files expl 'remote file or directory' \
       compadd -S/ -d remdispd ${remdispd##* }

- -elif compset -P 1 '*::'; then
+elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; then
+
+  local pat=${words[CURRENT]}

- -  remfiles=(${(f)"$(_call_program files rsync ${words[CURRENT]%::*}::)"})
+  if [[ $pat = *:: ]]; then
+    pat=${pat%::*}::
+  fi

- -  remmodules=(${remfiles/[     ]#/:})
+  remfiles=(${${(f)"$(_call_program files rsync $pat)"}:#[     ]*})
+
+  remmodules=(${remfiles/[     ]##/:})

   _describe "remote modules" remmodules -S/

+elif compset -P 'rsync://'; then
+  _rsync_user_or_host / "$@"
 elif compset -P 1 '*:'; then

   if zstyle -T ":completion:${curcontext}:files" remote-access; then
@@ -48,20 +77,8 @@ elif compset -P 1 '*:'; then
     _message -e remote-files 'remote file'
   fi

- -elif compset -P 1 '*@'; then
- -  local user=${PREFIX%%@*}
- -
- -  compset -S ':*' || suf=":"
- -
- -  _wanted -C user-at hosts expl "host for $user" \
- -      _combination -s '[:@]' "${tag}" users-hosts users="$user" hosts -S 
"$suf" "$@" -
 else
- -  if compset -S '@*'; then
- -    _wanted users expl "user" \
- -       _combination -s '[:@]' "${tag}" users-hosts users -q "$@" -
- -  else
- -    _alternative 'users:user:_users -S @' 'hosts:host:_hosts -S:'
- -  fi
+  _rsync_user_or_host : "$@"
 fi

 }
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCRdX9R6LMutpd94wRAhQuAKCWIjvT5S3FojItMvZux6X+MV+gUwCfUyGQ
+myYKLE5+EysA3rbNgjousA=
=clim
-----END PGP SIGNATURE-----


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

* Re: [PATCH] _rsync - better rsync:// URL support and other fixes
  2005-03-26 21:36 [PATCH] _rsync - better rsync:// URL support and other fixes Andrey Borzenkov
@ 2005-03-29 11:00 ` Oliver Kiddle
  2005-03-29 16:01   ` Bart Schaefer
  2005-04-03 11:34   ` Andrey Borzenkov
  0 siblings, 2 replies; 4+ messages in thread
From: Oliver Kiddle @ 2005-03-29 11:00 UTC (permalink / raw)
  To: zsh-workers

On 27 Mar, Andrey wrote:
> Absolutely ugly "compadd -S/ rsync:/" is the only way I know to add word with 
> two slashes without adding blank. Oliver, do you have any idea (the same 
> problem I had in _urpmi too).

It is possible to do:
  compadd -S '' rsync://

Or is there some problem with that?

> Oh, and I noticed that I never actually get `Host for "$user"' prompt.

_combination doesn't pass on descriptions. It may complete either users
or hosts and they have different descriptions.

Oliver


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

* Re: [PATCH] _rsync - better rsync:// URL support and other fixes
  2005-03-29 11:00 ` Oliver Kiddle
@ 2005-03-29 16:01   ` Bart Schaefer
  2005-04-03 11:34   ` Andrey Borzenkov
  1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2005-03-29 16:01 UTC (permalink / raw)
  To: zsh-workers

On Mar 29,  1:00pm, Oliver Kiddle wrote:
} Subject: Re: [PATCH] _rsync - better rsync:// URL support and other fixes
}
} On 27 Mar, Andrey wrote:
} > Oh, and I noticed that I never actually get `Host for "$user"' prompt.
} 
} _combination doesn't pass on descriptions. It may complete either users
} or hosts and they have different descriptions.

That reminds me ... I'm still using this patch:

diff -r1.1 _combination
91c91,93
<   compadd "$@" -a tmp || { (( $+functions[_$key] )) && "_$key" "$@" }
---
>   local expl
>   _wanted $key expl $key  compadd "$@" -a tmp ||
>       { (( $+functions[_$key] )) && "_$key" "$@" }

This is a crude workaround for some kind of bug in tag-order issue, see
zsh-workers/16598 and surrounding thread.  I have private mail from
Oliver back in August saying he's got a rewritten _combination, but it
doesn't look as if he's ever committed it, and the problem is really
in _arguments anyway?


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

* Re: [PATCH] _rsync - better rsync:// URL support and other fixes
  2005-03-29 11:00 ` Oliver Kiddle
  2005-03-29 16:01   ` Bart Schaefer
@ 2005-04-03 11:34   ` Andrey Borzenkov
  1 sibling, 0 replies; 4+ messages in thread
From: Andrey Borzenkov @ 2005-04-03 11:34 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 784 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 29 March 2005 15:00, Oliver Kiddle wrote:
> On 27 Mar, Andrey wrote:
> > Absolutely ugly "compadd -S/ rsync:/" is the only way I know to add word
> > with two slashes without adding blank. Oliver, do you have any idea (the
> > same problem I had in _urpmi too).
>
> It is possible to do:
>   compadd -S '' rsync://
>
> Or is there some problem with that?
>

No. Thank you.

The patch also fixes modules completion (broken in my last patch), stripes yet 
another MOTD (this starts to be amusing) and turns off rsync warnings.

- -andrey

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCT9StR6LMutpd94wRAkoAAJ9iPfU56lLxnzD7sf/PYI//QDMDyACePDzU
tMs/ttJxgosyiOkUOTLbgBM=
=nDnr
-----END PGP SIGNATURE-----

[-- Attachment #2: _rsync.diff --]
[-- Type: text/x-diff, Size: 1533 bytes --]

Index: Completion/Unix/Command/_rsync
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_rsync,v
retrieving revision 1.21
diff -u -p -r1.21 _rsync
--- Completion/Unix/Command/_rsync	28 Mar 2005 21:02:06 -0000	1.21
+++ Completion/Unix/Command/_rsync	3 Apr 2005 11:30:35 -0000
@@ -13,7 +13,7 @@ _rsync_user_or_host() {
       _wanted users expl "user" \
 	  _combination -s '[:@]' "${tag}" users-hosts users -q "$@" -
   else
-    [[ $words[CURRENT] = rsync://* ]] || rsync='rsync:rsync: compadd -S/ rsync:/'
+    [[ $words[CURRENT] = rsync://* ]] || rsync='rsync:rsync: compadd -S "" rsync://'
     _alternative \
       'users:user:_users -S @' \
       "hosts:host:_hosts -S '$suf'" \
@@ -26,7 +26,7 @@ local expl remfiles remdispf remdispd re
 
 if compset -P '*::*/' || compset -P 'rsync://*/*/'; then
 
-  remfiles=(${${(f)"$(_call_program files rsync ${words[CURRENT]%/*}/)"}:#[ 	]*})
+  remfiles=(${${(f)"$(_call_program files rsync ${words[CURRENT]%/*}/ 2>/dev/null)"}:#([ 	]|MOTD:)*})
 
   remdispf=(${remfiles:#d*})
   remdispd=(${(M)remfiles:#d*})
@@ -41,11 +41,13 @@ elif compset -P 1 '*::' || compset -P 1 
 
   local pat=${words[CURRENT]}
 
-  if [[ $pat = *:: ]]; then
+  if [[ $pat = *::* ]]; then
     pat=${pat%::*}::
+  else
+    pat=${pat%/*}/
   fi
 
-  remfiles=(${${(f)"$(_call_program files rsync $pat)"}:#[ 	]*})
+  remfiles=(${${(f)"$(_call_program files rsync $pat 2>/dev/null)"}:#([ 	]|MOTD:)*})
 
   remmodules=(${remfiles/[ 	]##/:})
 

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

end of thread, other threads:[~2005-04-03 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-26 21:36 [PATCH] _rsync - better rsync:// URL support and other fixes Andrey Borzenkov
2005-03-29 11:00 ` Oliver Kiddle
2005-03-29 16:01   ` Bart Schaefer
2005-04-03 11:34   ` Andrey Borzenkov

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