zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _ssh (scp)
@ 2002-02-04 17:59 Clint Adams
  2002-02-04 18:25 ` Bart Schaefer
  2002-02-05 10:24 ` Oliver Kiddle
  0 siblings, 2 replies; 10+ messages in thread
From: Clint Adams @ 2002-02-04 17:59 UTC (permalink / raw)
  To: zsh-workers; +Cc: david

So this is based on a patch from David Engel for something resembling
the current 4.0.x CVS.  Is it necessary to provide the echo behavior
as well, or can we safely assume that everything can do ls -d1F these
days?

Index: Completion/Unix/Command/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
retrieving revision 1.5
diff -u -r1.5 _ssh
--- Completion/Unix/Command/_ssh	2002/01/16 16:29:52	1.5
+++ Completion/Unix/Command/_ssh	2002/02/04 17:25:18
@@ -3,11 +3,16 @@
 _remote_files () {
   # This is extremely simple-minded; could parse "ls -F" output to do
   # colorings and LIST_TYPES and so on, but I'm just not that ambitious.
-  local expl
+  local expl remfiles
 
   if zstyle -T ":completion:${curcontext}:" remote-access; then
+    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${words[CURRENT]#*:}\*)"})
+
     _wanted files expl 'remote files' \
-        compadd $(ssh -a -x ${words[CURRENT]%:*} echo ${words[CURRENT]#*:}\*)
+      compadd ${${remfiles:#*/}/[*=@](#e)/}
+
+    _wanted dirs expl 'remote directories' \
+      compadd -S/ ${${(M)remfiles:#*/}/\\/(#e)/}
   else
     _message 'remote files'
   fi


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

* Re: PATCH: _ssh (scp)
  2002-02-04 17:59 PATCH: _ssh (scp) Clint Adams
@ 2002-02-04 18:25 ` Bart Schaefer
  2002-02-04 18:43   ` Clint Adams
  2002-02-05 10:24 ` Oliver Kiddle
  1 sibling, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2002-02-04 18:25 UTC (permalink / raw)
  To: Clint Adams, zsh-workers; +Cc: david

On Feb 4, 12:59pm, Clint Adams wrote:
} Subject: PATCH: _ssh (scp)
}
} So this is based on a patch from David Engel for something resembling
} the current 4.0.x CVS.  Is it necessary to provide the echo behavior
} as well, or can we safely assume that everything can do ls -d1F these
} days?

Assorted remarks:

This still needs the 2>/dev/null fix I described in 16533.

If you *are* going to parse "ls -F" output, you should remove the comment
that indicates otherwise.

Another possible approach would be to use ls (without -d) on the directory
parent of the remote path, and let the completion system filter out the
non-matching names, rather than the rather crude hack I did of appending
a `*' to the path.  This would support complete-in-word a bit better, but
means more network traffic.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: PATCH: _ssh (scp)
  2002-02-04 18:25 ` Bart Schaefer
@ 2002-02-04 18:43   ` Clint Adams
  0 siblings, 0 replies; 10+ messages in thread
From: Clint Adams @ 2002-02-04 18:43 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers, david

> This still needs the 2>/dev/null fix I described in 16533.

Right.  Patch below.  Also adds | to the bracket expression.
We still need a solution to the zle redisplay problem.

> If you *are* going to parse "ls -F" output, you should remove the comment
> that indicates otherwise.

Well, it's not doing colorings, but I'll modify the comment.

> Another possible approach would be to use ls (without -d) on the directory
> parent of the remote path, and let the completion system filter out the
> non-matching names, rather than the rather crude hack I did of appending
> a `*' to the path.  This would support complete-in-word a bit better, but
> means more network traffic.

That should probably be configurable via an adjunct to the remote-access
style then.

Index: Completion/Unix/Command/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
retrieving revision 1.6
diff -u -r1.6 _ssh
--- Completion/Unix/Command/_ssh	2002/02/04 18:03:25	1.6
+++ Completion/Unix/Command/_ssh	2002/02/04 18:40:48
@@ -1,15 +1,15 @@
 #compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen
 
 _remote_files () {
-  # This is extremely simple-minded; could parse "ls -F" output to do
-  # colorings and LIST_TYPES and so on, but I'm just not that ambitious.
+  # Rather than simple directory discrimination, there should be
+  # coloring based on all the different ls -F classifiers.
   local expl remfiles
 
   if zstyle -T ":completion:${curcontext}:" remote-access; then
-    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${words[CURRENT]#*:}\*)"})
+    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${words[CURRENT]#*:}\* 2>/dev/null)"})
 
     _wanted files expl 'remote files' \
-      compadd ${${remfiles:#*/}/[*=@](#e)/}
+      compadd ${${remfiles:#*/}/[*=@|](#e)/}
 
     _wanted dirs expl 'remote directories' \
       compadd -S/ ${${(M)remfiles:#*/}/\\/(#e)/}


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

* Re: PATCH: _ssh (scp)
  2002-02-04 17:59 PATCH: _ssh (scp) Clint Adams
  2002-02-04 18:25 ` Bart Schaefer
@ 2002-02-05 10:24 ` Oliver Kiddle
  2002-02-05 17:47   ` Clint Adams
  1 sibling, 1 reply; 10+ messages in thread
From: Oliver Kiddle @ 2002-02-05 10:24 UTC (permalink / raw)
  To: zsh-workers; +Cc: david

Clint wrote:

>      _wanted files expl 'remote files' \
> -        compadd $(ssh -a -x ${words[CURRENT]%:*} echo
> ${words[CURRENT]#*:}\*)
> +      compadd ${${remfiles:#*/}/[*=@](#e)/}
> +
> +    _wanted dirs expl 'remote directories' \
> +      compadd -S/ ${${(M)remfiles:#*/}/\\/(#e)/}

It would be more consistent with normal file completion to add the
files and directories together with the same tag and description.
I'd also be tempted to setup separate display strings so that the * for
executables, @ for symlinks etc are preserved in the file list.

Is it possible to have colour coding work in this sort of case? When I
did _mtools I briefly looked but couldn't see how it could be done.

Oliver

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


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

* Re: PATCH: _ssh (scp)
  2002-02-05 10:24 ` Oliver Kiddle
@ 2002-02-05 17:47   ` Clint Adams
  2002-02-05 18:08     ` Clint Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Clint Adams @ 2002-02-05 17:47 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers, david

> It would be more consistent with normal file completion to add the
> files and directories together with the same tag and description.
> I'd also be tempted to setup separate display strings so that the * for
> executables, @ for symlinks etc are preserved in the file list.

This does that somewhat messily.

I intend to revert the bit where it checks PREFIX and in all cases
have it do an ls on the dirname.

However, I can't decide if it is better to
ls -a1F /dir (thereby getting all the dotfiles and potentially
respecting the local setting of GLOB_DOTS)
or
ls -d1F /dir/* (thereby respecting the remote setting of GLOB_DOTS or
equivalent)

Index: Completion/Unix/Command/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
retrieving revision 1.7
diff -u -r1.7 _ssh
--- Completion/Unix/Command/_ssh	2002/02/04 18:44:23	1.7
+++ Completion/Unix/Command/_ssh	2002/02/05 17:35:42
@@ -1,18 +1,26 @@
 #compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen
 
 _remote_files () {
-  # Rather than simple directory discrimination, there should be
-  # coloring based on all the different ls -F classifiers.
-  local expl remfiles
+  # There should be coloring based on all the different ls -F classifiers.
+  local expl remfiles remdispf remdispd
 
   if zstyle -T ":completion:${curcontext}:" remote-access; then
-    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${words[CURRENT]#*:}\* 2>/dev/null)"})
+    if [[ $options[globdots] == "on" ]] && [[ "$PREFIX" == */ || -z "$PREFIX" ]];
+    then
+      print ssh -a -x ${words[CURRENT]%:*} ls -a1F ${words[CURRENT]#*:}
+      remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -a1F ${words[CURRENT]#*:} 2>/dev/null)"})
+    else
+      remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${words[CURRENT]#*:}\* 2>/dev/null)"})
+    fi
 
-    _wanted files expl 'remote files' \
-      compadd ${${remfiles:#*/}/[*=@|](#e)/}
+    remdispf=(${remfiles:#*/})
+    remdispd=(${(M)remfiles:#*/})
 
-    _wanted dirs expl 'remote directories' \
-      compadd -S/ ${${(M)remfiles:#*/}/\\/(#e)/}
+    _wanted files expl 'remote files and directories' \
+      compadd -d remdispf ${${remfiles:#*/}/[*=@|](#e)/}
+      
+    _wanted files expl 'remote files and directories' \
+      compadd -S/ -d remdispd ${${(M)remfiles:#*/}/\\/(#e)/}
   else
     _message 'remote files'
   fi


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

* Re: PATCH: _ssh (scp)
  2002-02-05 17:47   ` Clint Adams
@ 2002-02-05 18:08     ` Clint Adams
  2002-02-05 18:38       ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: Clint Adams @ 2002-02-05 18:08 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers, david

> ls -a1F /dir (thereby getting all the dotfiles and potentially
> respecting the local setting of GLOB_DOTS)
> or
> ls -d1F /dir/* (thereby respecting the remote setting of GLOB_DOTS or
> equivalent)

I opted for the latter, but it doesn't quite work.

3.0.8% SLASH=/
3.0.8% print $SLASH
/
3.0.8% print $SLASH:h
/

4.0.4% SLASH=/
4.0.4% print $SLASH
/
4.0.4% print $SLASH:h
.

Was this change intentional?

Index: Completion/Unix/Command/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
retrieving revision 1.8
diff -u -r1.8 _ssh
--- Completion/Unix/Command/_ssh	2002/02/05 18:03:26	1.8
+++ Completion/Unix/Command/_ssh	2002/02/05 18:05:04
@@ -5,13 +5,7 @@
   local expl remfiles remdispf remdispd
 
   if zstyle -T ":completion:${curcontext}:" remote-access; then
-    if [[ $options[globdots] == "on" ]] && [[ "$PREFIX" == */ || -z "$PREFIX" ]];
-    then
-      print ssh -a -x ${words[CURRENT]%:*} ls -a1F ${words[CURRENT]#*:}
-      remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -a1F ${words[CURRENT]#*:} 2>/dev/null)"})
-    else
-      remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${words[CURRENT]#*:}\* 2>/dev/null)"})
-    fi
+    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${${${words[CURRENT]#*:}:h}/\\/(#e)/}/\* 2>/dev/null)"})
 
     remdispf=(${remfiles:#*/})
     remdispd=(${(M)remfiles:#*/})


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

* Re: PATCH: _ssh (scp)
  2002-02-05 18:08     ` Clint Adams
@ 2002-02-05 18:38       ` Bart Schaefer
  2002-02-06 16:43         ` Clint Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2002-02-05 18:38 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-workers

On Feb 5,  1:08pm, Clint Adams wrote:
}
} 4.0.4% SLASH=/
} 4.0.4% print $SLASH:h
} .
} 
} Was this change intentional?

There was a change to make :h behave more as if it knew about file structure,
but I'm quite sure that turning `/' into `.' was not an intended effect, and
in fact it looks like a serious bug to me.


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: PATCH: _ssh (scp)
  2002-02-05 18:38       ` Bart Schaefer
@ 2002-02-06 16:43         ` Clint Adams
  2002-02-06 16:59           ` Borsenkow Andrej
  0 siblings, 1 reply; 10+ messages in thread
From: Clint Adams @ 2002-02-06 16:43 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> There was a change to make :h behave more as if it knew about file structure,
> but I'm quite sure that turning `/' into `.' was not an intended effect, and
> in fact it looks like a serious bug to me.

Is the following acceptable behavior on Cygwin?

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.36
diff -u -r1.36 hist.c
--- Src/hist.c	2001/10/26 23:47:10	1.36
+++ Src/hist.c	2002/02/06 16:38:14
@@ -1378,7 +1378,11 @@
     while (str >= *junkptr && !IS_DIRSEP(*str))
 	--str;
     if (str < *junkptr) {
-	*junkptr = dupstring (".");
+	if (IS_DIRSEP(**junkptr))
+	    *junkptr = dupstring ("/");
+	else
+	    *junkptr = dupstring (".");
+
 	return 0;
     }
     /* repeated slashes are considered like a single slash */


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

* RE: PATCH: _ssh (scp)
  2002-02-06 16:43         ` Clint Adams
@ 2002-02-06 16:59           ` Borsenkow Andrej
  2002-02-06 18:12             ` The :h modifier Brass Lantern Enterprises
  0 siblings, 1 reply; 10+ messages in thread
From: Borsenkow Andrej @ 2002-02-06 16:59 UTC (permalink / raw)
  To: 'Clint Adams', 'Bart Schaefer'; +Cc: zsh-workers

> 
> Is the following acceptable behavior on Cygwin?
>

Assuming that for foo=/ ${foo:t} is empty - yes. Of course for full
support we should do something or //server/share and x:\path but it is
way too much currently. Actually at some point I guess we silently
decided to not discuss any issues with \ as directory separator :-)

-andrej


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

* The :h modifier
  2002-02-06 16:59           ` Borsenkow Andrej
@ 2002-02-06 18:12             ` Brass Lantern Enterprises
  0 siblings, 0 replies; 10+ messages in thread
From: Brass Lantern Enterprises @ 2002-02-06 18:12 UTC (permalink / raw)
  To: Borsenkow Andrej; +Cc: zsh-workers

On Wed, 6 Feb 2002, Borsenkow Andrej wrote:

> Of course for full support we should do something or //server/share
> and x:\path but it is way too much currently. Actually at some point I
> guess we silently decided to not discuss any issues with \ as
> directory separator :-)

We didn't "silently" decide that -- as I recall it was pretty noisy.

It's a bit difficult to do a search for this sort of thing in the
archives, but see for example the thread from 2000 with ":r modifier"
in the subject.


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

end of thread, other threads:[~2002-02-06 18:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-04 17:59 PATCH: _ssh (scp) Clint Adams
2002-02-04 18:25 ` Bart Schaefer
2002-02-04 18:43   ` Clint Adams
2002-02-05 10:24 ` Oliver Kiddle
2002-02-05 17:47   ` Clint Adams
2002-02-05 18:08     ` Clint Adams
2002-02-05 18:38       ` Bart Schaefer
2002-02-06 16:43         ` Clint Adams
2002-02-06 16:59           ` Borsenkow Andrej
2002-02-06 18:12             ` The :h modifier Brass Lantern Enterprises

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