Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: 3.1.4: autocd to directory in $PATH
- X-seq: zsh-workers 4423
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: PATCH: 3.1.4: autocd to directory in $PATH
- Date: Fri, 9 Oct 1998 10:16:01 -0700
- In-reply-to: <9810031530.AA20041@xxxxxxxxxxxxxxxxx>
- References: <9810031530.AA20041@xxxxxxxxxxxxxxxxx>
On Oct 3, 5:30pm, Peter Stephenson wrote:
} Subject: PATCH: 3.1.4: autocd to directory in $PATH
}
} at the moment it looks to me like nothing other than the full
} stat() horror would be a really worthwhile improvement on
[...]
} ***************
} *** 1489,1494 ****
} --- 1502,1509 ----
} char *cmdarg = (char *) peekfirst(args);
}
} hn = cmdnamtab->getnode(cmdnamtab, cmdarg);
} + if (hn && !isreallycom((Cmdnam)hn))
} + hn = NULL;
} if (!hn && isset(HASHCMDS) && strcmp(cmdarg, "..")) {
} for (s = cmdarg; *s && *s != '/'; s++);
} if (!*s)
hn = (HashNode) hashcmd(cmdarg, pathchecked);
(One more line of context added for clarity.)
I haven't actually walked through this with a debugger, but it looks to
me as though hn = NULL at that point is going to trigger the call to
hashcmd(cmdarg, pathchecked), which in turn is going to call iscom() a
second time; so you end up stat()ing the directory twice. Perhaps
if (hn && !isreallycom((Cmdnam)hn))
hn = NULL;
else if (!hn && isset(HASHCMDS) && strcmp(cmdarg, "..")) {
^^^^
would be better?
Also, what about removing the improperly hashed directory from cmdnamtab
once you've discovered that it isn't a command? That would (I think) get
any real command with the same name put into the table the next time that
name was used, so that you'll never needlessly stat() again.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author