zsh-workers
 help / color / mirror / code / Atom feed
* Completion doesn't work on symlink to . with ignore-parents
@ 2010-06-29  8:54 Vincent Lefevre
  2010-07-26 12:41 ` Vincent Lefevre
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Lefevre @ 2010-06-29  8:54 UTC (permalink / raw)
  To: zsh-workers

Hi,

ypig% ln -s . symlink
ypig% ls -l symlink
lrwxrwxrwx 1 vlefevre vlefevre 1 2010-06-29 10:48:49 symlink -> .
ypig% zstyle ':completion:*' completer _complete
ypig% zstyle ':completion:*' ignore-parents parent pwd
ypig% autoload -U compinit
ypig% compinit
ypig% rm sym[TAB]

doesn't complete to anything.

I have zsh 4.3.10 with some patches.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


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

* Re: Completion doesn't work on symlink to . with ignore-parents
  2010-06-29  8:54 Completion doesn't work on symlink to . with ignore-parents Vincent Lefevre
@ 2010-07-26 12:41 ` Vincent Lefevre
  2010-07-26 13:07   ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Lefevre @ 2010-07-26 12:41 UTC (permalink / raw)
  To: zsh-workers

Hi,

On 2010-06-29 10:54:49 +0200, Vincent Lefevre wrote:
> ypig% ln -s . symlink
> ypig% ls -l symlink
> lrwxrwxrwx 1 vlefevre vlefevre 1 2010-06-29 10:48:49 symlink -> .
> ypig% zstyle ':completion:*' completer _complete
> ypig% zstyle ':completion:*' ignore-parents parent pwd
> ypig% autoload -U compinit
> ypig% compinit
> ypig% rm sym[TAB]
> 
> doesn't complete to anything.
> 
> I have zsh 4.3.10 with some patches.

Any news? This problem still occurs with zsh 4.3.10-dev-2.

To make sure this report doesn't get lost (and hoping that the bug
will be fixed before the next Debian release), I've also reported
it here:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=590454

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


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

* Re: Completion doesn't work on symlink to . with ignore-parents
  2010-07-26 12:41 ` Vincent Lefevre
@ 2010-07-26 13:07   ` Peter Stephenson
  2010-07-27 12:06     ` Vincent Lefevre
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2010-07-26 13:07 UTC (permalink / raw)
  To: zsh-workers

On Mon, 26 Jul 2010 14:41:18 +0200
Vincent Lefevre <vincent@vinc17.net> wrote:
> On 2010-06-29 10:54:49 +0200, Vincent Lefevre wrote:
> > ypig% ln -s . symlink
> > ypig% ls -l symlink
> > lrwxrwxrwx 1 vlefevre vlefevre 1 2010-06-29 10:48:49 symlink -> .
> > ypig% zstyle ':completion:*' completer _complete
> > ypig% zstyle ':completion:*' ignore-parents parent pwd
> > ypig% autoload -U compinit
> > ypig% compinit
> > ypig% rm sym[TAB]
> > 
> > doesn't complete to anything.
> > 
> > I have zsh 4.3.10 with some patches.
> 
> Any news? This problem still occurs with zsh 4.3.10-dev-2.

It might be this simple.  The function in question appears only to do
comparison on device and inode.  If, as this bug report suggests, it's
wrong to ignore symbolic links to the file in question, then always doing
an lstat() is presumably correct.  However, the function is about three
levels of undocumentation deep inside the completion system.  I've added a
lonely comment saying what I think is going on.

Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.118
diff -p -u -r1.118 computil.c
--- Src/Zle/computil.c	22 Jan 2010 20:42:32 -0000	1.118
+++ Src/Zle/computil.c	26 Jul 2010 13:05:38 -0000
@@ -4653,6 +4653,15 @@ cf_pats(int dirs, int noopt, LinkList na
 			 names, skipped, sdirs, fake);
 }
 
+/*
+ * This function looks at device/inode pairs to determine if
+ * a file is one we should ignore because of its relationship
+ * to the current or parent directory.
+ *
+ * We don't follow symbolic links here, because typically
+ * a user will not want an explicit link to the current or parent
+ * directory ignored.
+ */
 static void
 cf_ignore(char **names, LinkList ign, char *style, char *path)
 {
@@ -4661,14 +4670,14 @@ cf_ignore(char **names, LinkList ign, ch
     char *n, *c, *e;
 
     tpar = !!strstr(style, "parent");
-    if ((tpwd = !!strstr(style, "pwd")) && stat(pwd, &est))
+    if ((tpwd = !!strstr(style, "pwd")) && lstat(pwd, &est))
 	tpwd = 0;
 
     if (!tpar && !tpwd)
 	return;
 
     for (; (n = *names); names++) {
-	if (!ztat(n, &nst, 0) && S_ISDIR(nst.st_mode)) {
+	if (!ztat(n, &nst, 1) && S_ISDIR(nst.st_mode)) {
 	    if (tpwd && nst.st_dev == est.st_dev && nst.st_ino == est.st_ino) {
 		addlinknode(ign, quotestring(n, NULL, QT_BACKSLASH));
 		continue;
@@ -4684,7 +4693,7 @@ cf_ignore(char **names, LinkList ign, ch
 		    }
 		}
 		if (found || ((e = strrchr(c, '/')) && e > c + pl &&
-			      !ztat(c, &st, 0) && st.st_dev == nst.st_dev &&
+			      !ztat(c, &st, 1) && st.st_dev == nst.st_dev &&
 			      st.st_ino == nst.st_ino))
 		    addlinknode(ign, quotestring(n, NULL, QT_BACKSLASH));
 	    }
-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: Completion doesn't work on symlink to . with ignore-parents
  2010-07-26 13:07   ` Peter Stephenson
@ 2010-07-27 12:06     ` Vincent Lefevre
  0 siblings, 0 replies; 4+ messages in thread
From: Vincent Lefevre @ 2010-07-27 12:06 UTC (permalink / raw)
  To: zsh-workers

On 2010-07-26 14:07:26 +0100, Peter Stephenson wrote:
> It might be this simple.  The function in question appears only to do
> comparison on device and inode.  If, as this bug report suggests, it's
> wrong to ignore symbolic links to the file in question, then always doing
> an lstat() is presumably correct.  However, the function is about three
> levels of undocumentation deep inside the completion system.  I've added a
> lonely comment saying what I think is going on.

Thanks. I confirm that this fixes the problem here.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


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

end of thread, other threads:[~2010-07-27 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-29  8:54 Completion doesn't work on symlink to . with ignore-parents Vincent Lefevre
2010-07-26 12:41 ` Vincent Lefevre
2010-07-26 13:07   ` Peter Stephenson
2010-07-27 12:06     ` Vincent Lefevre

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