zsh-users
 help / color / mirror / code / Atom feed
* Remote scp completion that can handle spaces etc. in pathnames
@ 2003-02-13 13:30 Hannu Koivisto
  2003-02-13 14:41 ` Oliver Kiddle
  0 siblings, 1 reply; 5+ messages in thread
From: Hannu Koivisto @ 2003-02-13 13:30 UTC (permalink / raw)
  To: Zsh Users' List

Greetings,

Let's say that there is a directory "foo bar" on host baz.  If I
try to copy it recursively with scp from baz to the current host, I
have to say ``scp -r baz:foo\\\ bar .''  That is, I need to
"double quote".  However, if I use zsh's completion to get me that
directory, i.e. I write ``scp -r baz:fo<tab>'', I get
``scp -r baz:foo\ bar/'', which does not work.

I use openssh 3.4p1 and zsh 4.0.4 on Debian GNU/Linux woody.  Is
this handled differently in a later (stable or development) version
and/or would this be easy to fix locally?

I also note that pathnames in remote commands are not completed
remotely, i.e. if I write ``ssh somehost ls f<tab>'', zsh completes
local filesystem entries beginning with f.  I wonder if this could
be smarter as well.

-- 
Hannu
Please don't send copies of list mail


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

* Re: Remote scp completion that can handle spaces etc. in pathnames
  2003-02-13 13:30 Remote scp completion that can handle spaces etc. in pathnames Hannu Koivisto
@ 2003-02-13 14:41 ` Oliver Kiddle
  2003-02-13 15:06   ` Hannu Koivisto
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2003-02-13 14:41 UTC (permalink / raw)
  To: Hannu Koivisto; +Cc: zsh-users

On 13 Feb, you wrote:
> 
> Let's say that there is a directory "foo bar" on host baz.  If I
> try to copy it recursively with scp from baz to the current host, I
> have to say ``scp -r baz:foo\\\ bar .''  That is, I need to
> "double quote".  However, if I use zsh's completion to get me that
> directory, i.e. I write ``scp -r baz:fo<tab>'', I get
> ``scp -r baz:foo\ bar/'', which does not work.
> 
> I use openssh 3.4p1 and zsh 4.0.4 on Debian GNU/Linux woody.  Is
> this handled differently in a later (stable or development) version
> and/or would this be easy to fix locally?

Patch below should fix this. _ssh has changed a bit since 4.0.4 so I'm
not sure how easy it would be to modify for that.

> I also note that pathnames in remote commands are not completed
> remotely, i.e. if I write ``ssh somehost ls f<tab>'', zsh completes
> local filesystem entries beginning with f.  I wonder if this could
> be smarter as well.

It could possibly be done by somehow doing a temporary substitution of
_path_files by _remote_files but saving the original _path_files and
doing any other necessary fiddling would be more than a bit messy so I'm
not going to attempt it.

Oliver

Index: Completion/Unix/Command/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
retrieving revision 1.18
diff -u -r1.18 _ssh
--- Completion/Unix/Command/_ssh	7 Jan 2003 08:49:16 -0000	1.18
+++ Completion/Unix/Command/_ssh	13 Feb 2003 14:29:21 -0000
@@ -17,9 +17,9 @@
     while _tags; do
       while _next_label files expl ${suf:-remote directory}; do
         [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
-	    ${remdispf%[*=@|]} && ret=0 
+	    ${(q)remdispf%[*=@|]} && ret=0 
 	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
-	    ${remdispd%/} && ret=0
+	    ${(q)remdispd%/} && ret=0
       done
       (( ret )) || return 0
     done

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


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

* Re: Remote scp completion that can handle spaces etc. in pathnames
  2003-02-13 14:41 ` Oliver Kiddle
@ 2003-02-13 15:06   ` Hannu Koivisto
  2003-02-13 16:12     ` Oliver Kiddle
  0 siblings, 1 reply; 5+ messages in thread
From: Hannu Koivisto @ 2003-02-13 15:06 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

Oliver Kiddle <okiddle@yahoo.co.uk> writes:

> Patch below should fix this. _ssh has changed a bit since 4.0.4 so I'm
> not sure how easy it would be to modify for that.

Thanks!  It applied to 4.0.4 just fine.  However, I needed 
an additional modification to make it work with filenames such as
``[foo bar* |'' -- * and | didn't appear at all without this
modification.  I wonder if this breaks something elsewhere?  See
the modification below, within your patch.

>> I also note that pathnames in remote commands are not completed
>> remotely, i.e. if I write ``ssh somehost ls f<tab>'', zsh completes
>> local filesystem entries beginning with f.  I wonder if this could
>> be smarter as well.
>
> It could possibly be done by somehow doing a temporary substitution of
> _path_files by _remote_files but saving the original _path_files and
> doing any other necessary fiddling would be more than a bit messy so I'm
> not going to attempt it.

Ok, I can certainly live without such a feature.

> Oliver
>
> Index: Completion/Unix/Command/_ssh
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
> retrieving revision 1.18
> diff -u -r1.18 _ssh
> --- Completion/Unix/Command/_ssh	7 Jan 2003 08:49:16 -0000	1.18
> +++ Completion/Unix/Command/_ssh	13 Feb 2003 14:29:21 -0000
> @@ -17,9 +17,9 @@
>      while _tags; do
>        while _next_label files expl ${suf:-remote directory}; do
>          [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
> -	    ${remdispf%[*=@|]} && ret=0 
> +	    ${(q)remdispf%[*=@|]} && ret=0 

I replaced the above line with this:

+	    ${(q)remdispf%[=@]} && ret=0 

>  	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
> -	    ${remdispd%/} && ret=0
> +	    ${(q)remdispd%/} && ret=0
>        done
>        (( ret )) || return 0
>      done

-- 
Hannu


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

* Re: Remote scp completion that can handle spaces etc. in pathnames
  2003-02-13 15:06   ` Hannu Koivisto
@ 2003-02-13 16:12     ` Oliver Kiddle
  2003-02-17  9:18       ` Hannu Koivisto
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2003-02-13 16:12 UTC (permalink / raw)
  To: Hannu Koivisto; +Cc: zsh-users

Hannu Koivisto wrote:
> 
> Thanks!  It applied to 4.0.4 just fine.  However, I needed 
> an additional modification to make it work with filenames such as
> ``[foo bar* |'' -- * and | didn't appear at all without this
> modification.  I wonder if this breaks something elsewhere?  See
> the modification below, within your patch.

The completion for ssh uses ls -F on the remote machine to get the files
and then takes trailing *, =, |, / and @ characters to be the characters
added by ls -F to indicate the type of the file. I don't tend to have
file names ending in those characters and find it useful that it does
this. The ssh completion should perhaps honour the list_types style but
it'd still need ls -F to be able to do add `/' suffixes for directories.

Oliver

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


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

* Re: Remote scp completion that can handle spaces etc. in pathnames
  2003-02-13 16:12     ` Oliver Kiddle
@ 2003-02-17  9:18       ` Hannu Koivisto
  0 siblings, 0 replies; 5+ messages in thread
From: Hannu Koivisto @ 2003-02-17  9:18 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

Oliver Kiddle <okiddle@yahoo.co.uk> writes:

> The completion for ssh uses ls -F on the remote machine to get the files
> and then takes trailing *, =, |, / and @ characters to be the characters

Ah, so it does indeed.  I wonder if listing could be done in some
other, more robust way.  The availability of programs on the remote
machine obviously limits the possible ways...  Perhaps find could
be used?

> added by ls -F to indicate the type of the file. I don't tend to have
> file names ending in those characters and find it useful that it does
> this. The ssh completion should perhaps honour the list_types style but

I don't usually have file names ending in those characters either
(someone else whose files I need to copy might have, though) and
one of the reasons I use zsh is that in general it handles even the
corner cases well unlike so many other programs.  Programmers who
think "oh well, no one should put spaces to filenames anyway" and
do not handle the filenames allowed by the relevant standards are
the cause to problems like Y2k.  Of course, in this case zsh is at
the mercy of programs that make it hard to be robust, so it is
understandable if it cannot be done (I guess it would be nice if it
was documented somewhere, however).

-- 
Hannu


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

end of thread, other threads:[~2003-02-17  9:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 13:30 Remote scp completion that can handle spaces etc. in pathnames Hannu Koivisto
2003-02-13 14:41 ` Oliver Kiddle
2003-02-13 15:06   ` Hannu Koivisto
2003-02-13 16:12     ` Oliver Kiddle
2003-02-17  9:18       ` Hannu Koivisto

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