zsh-workers
 help / color / mirror / code / Atom feed
* Strange behavior of autocd under IRIX 6.2
@ 1996-10-31 16:44 Bart Schaefer
  1996-10-31 17:00 ` Zoltan Hidvegi
  1996-11-01  4:59 ` Hideki ONO
  0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 1996-10-31 16:44 UTC (permalink / raw)
  To: zsh-workers

A friend who is not on the mailing lists reports that, under IRIX 6 only,
autocd doesn't work for the directory ".." (parent directory) unless you
use something like "./.." or "../".  He says it works using just ".." in
Linux 2.0 and in SunOS, same version of zsh; but not in IRIX 6, where it
produces "command not found".

I don't have access to an IRIX machine any longer, so I can't try this.
Has anyone else seen anything like it?  Any ideas?

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: Strange behavior of autocd under IRIX 6.2
  1996-10-31 16:44 Strange behavior of autocd under IRIX 6.2 Bart Schaefer
@ 1996-10-31 17:00 ` Zoltan Hidvegi
  1996-11-01  4:59 ` Hideki ONO
  1 sibling, 0 replies; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-10-31 17:00 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
> A friend who is not on the mailing lists reports that, under IRIX 6 only,
> autocd doesn't work for the directory ".." (parent directory) unless you
> use something like "./.." or "../".  He says it works using just ".." in
> Linux 2.0 and in SunOS, same version of zsh; but not in IRIX 6, where it
> produces "command not found".

Under IRIX 5.3 it works fine.

Zoltan


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

* Re: Strange behavior of autocd under IRIX 6.2
  1996-10-31 16:44 Strange behavior of autocd under IRIX 6.2 Bart Schaefer
  1996-10-31 17:00 ` Zoltan Hidvegi
@ 1996-11-01  4:59 ` Hideki ONO
  1996-11-01  6:25   ` Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: Hideki ONO @ 1996-11-01  4:59 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-workers

> A friend who is not on the mailing lists reports that, under IRIX 6 only,
> autocd doesn't work for the directory ".." (parent directory) unless you
> use something like "./.." or "../".  He says it works using just ".." in
> Linux 2.0 and in SunOS, same version of zsh; but not in IRIX 6, where it
> produces "command not found".

I have a same problem under IRIX6.2. It is because command ".." is
hashed in cmdnamtab.

When I execute opendir() with directory "/usr/bsd" in hashdir(),
1st readdir() returns "."
2nd readdir() returns "w"
3rd readdir() returns ".."
And, ".." is hashed in cmdnamtab.

--
ONO Hideki  <ono@tamaru.kuee.kyoto-u.ac.jp>	
Department of Electronics and Communication
Graduate School of Engineering
Kyoto University, Japan


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

* Re: Strange behavior of autocd under IRIX 6.2
  1996-11-01  4:59 ` Hideki ONO
@ 1996-11-01  6:25   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1996-11-01  6:25 UTC (permalink / raw)
  To: Hideki ONO; +Cc: zsh-workers

On Nov 1,  1:59pm, Hideki ONO wrote:
} Subject: Re: Strange behavior of autocd under IRIX 6.2
}
} I have a same problem under IRIX6.2. It is because command ".." is
} hashed in cmdnamtab.
} 
} When I execute opendir() with directory "/usr/bsd" in hashdir(),
} 1st readdir() returns "."
} 2nd readdir() returns "w"
} 3rd readdir() returns ".."
} And, ".." is hashed in cmdnamtab.

It's really bad form for zsh to assume without looking that the first
two directory entries are always "." and "..".  As evidenced here, this
is not always a valid assumption.  There appear to be four places in the
source (two in one function alone!) that blindly readdir(); readdir();
after first opening the directory, without even looking at the results.
However, gen_matches_files() and scanner() do it the right way, so here's
a patch that changes everything else to do as those do.

Index: Src/compat.c
--- Src/compat.c.0	Sat Jul 27 13:24:36 1996
+++ Src/compat.c	Thu Oct 31 22:08:02 1996
@@ -153,20 +153,29 @@
 	    return ztrdup(".");
 	}
 	chdir("..");
-	readdir(dir);
-	readdir(dir);
-	while ((de = readdir(dir)))
+	while ((de = readdir(dir))) {
+	    char *fn = de->d_name;
+	    /* Ignore `.' and `..'. */
+	    if (fn[0] == '.' &&
+		(fn[1] == '\0' ||
+		 (fn[1] == '.' && fn[2] == '\0')))
+		continue;
 	    if ((ino_t) de->d_ino == ino) {
-		lstat(de->d_name, &sbuf);
+		lstat(fn, &sbuf);
 		if (sbuf.st_dev == dev)
 		    goto match;
 	    }
+	}
 	closedir(dir);
 	dir = opendir(".");
-	readdir(dir);
-	readdir(dir);
 	while ((de = readdir(dir))) {
-	    lstat(de->d_name, &sbuf);
+	    char *fn = de->d_name;
+	    /* Ignore `.' and `..'. */
+	    if (fn[0] == '.' &&
+		(fn[1] == '\0' ||
+		 (fn[1] == '.' && fn[2] == '\0')))
+		continue;
+	    lstat(fn, &sbuf);
 	    if (sbuf.st_dev == dev)
 		goto match;
 	}
Index: Src/hashtable.c
--- Src/hashtable.c.0	Fri Jul 26 05:09:46 1996
+++ Src/hashtable.c	Thu Oct 31 22:22:12 1996
@@ -546,14 +546,18 @@
     if (isrelative(*dirp) || !(dir = opendir(unmeta(*dirp))))
 	return;
 
-    readdir(dir);
-    readdir(dir);
     while ((de = zreaddir(dir))) {
-	if (!cmdnamtab->getnode(cmdnamtab, de->d_name)) {
+	char *fn = de->d_name;
+	/* Ignore `.' and `..'. */
+	if (fn[0] == '.' &&
+	    (fn[1] == '\0' ||
+	     (fn[1] == '.' && fn[2] == '\0')))
+	    continue;
+	if (!cmdnamtab->getnode(cmdnamtab, fn)) {
 	    cn = (Cmdnam) zcalloc(sizeof *cn);
 	    cn->flags = 0;
 	    cn->u.name = dirp;
-	    cmdnamtab->addnode(cmdnamtab, ztrdup(de->d_name), cn);
+	    cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn);
 	}
     }
     closedir(dir);
Index: Src/utils.c
--- Src/utils.c.0	Thu Oct 10 04:05:11 1996
+++ Src/utils.c	Thu Oct 31 22:14:00 1996
@@ -662,18 +662,23 @@
 	    int ct = 1;
 
 	    if (lock) {
+		char *fn;
 		HEAPALLOC {
 		    pushheap();
 		    l = newlinklist();
-		    readdir(lock);
-		    readdir(lock);
 		    while ((de = zreaddir(lock))) {
 			if (errflag)
 			    break;
+			fn = de->d_name;
+			/* Ignore `.' and `..'. */
+			if (fn[0] == '.' &&
+			    (fn[1] == '\0' ||
+			     (fn[1] == '.' && fn[2] == '\0')))
+			    continue;
 			if (u)
-			    sprintf(buf, "%s/%s?%s", *s, de->d_name, u);
+			    sprintf(buf, "%s/%s?%s", *s, fn, u);
 			else
-			    sprintf(buf, "%s/%s", *s, de->d_name);
+			    sprintf(buf, "%s/%s", *s, fn);
 			addlinknode(l, dupstring(buf));
 			ct++;
 		    }

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

end of thread, other threads:[~1996-11-01  6:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-31 16:44 Strange behavior of autocd under IRIX 6.2 Bart Schaefer
1996-10-31 17:00 ` Zoltan Hidvegi
1996-11-01  4:59 ` Hideki ONO
1996-11-01  6:25   ` Bart Schaefer

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