Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug with $PWD in /



On Sep 16,  5:26pm, Stephane Chazelas wrote:
} 
} It looks like zsh has a similar issue as bash as reported at:
} http://thread.gmane.org/gmane.comp.shells.bash.bugs/24162

How about this?

diff --git a/Src/utils.c b/Src/utils.c
index 1de3d95..0016fa1 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -692,9 +692,19 @@ ispwd(char *s)
 {
     struct stat sbuf, tbuf;
 
-    if (stat(unmeta(s), &sbuf) == 0 && stat(".", &tbuf) == 0)
-	if (sbuf.st_dev == tbuf.st_dev && sbuf.st_ino == tbuf.st_ino)
-	    return 1;
+    if (stat((s = unmeta(s)), &sbuf) == 0 && stat(".", &tbuf) == 0)
+	if (sbuf.st_dev == tbuf.st_dev && sbuf.st_ino == tbuf.st_ino) {
+	    /* POSIX: No element of $PWD may be "." or ".." */
+	    while (*s) {
+		if (s[0] == '.' &&
+		    (!s[1] || s[1] == '/' ||
+		     (s[1] == '.' && (!s[2] || s[2] == '/'))))
+		    break;
+		while (*s++ != '/' && *s)
+		    continue;
+	    }
+	    return !*s;
+	}
     return 0;
 }
 



Messages sorted by: Reverse Date, Date, Thread, Author