zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.4: autocd to directory in $PATH
@ 1998-10-03 15:30 Peter Stephenson
  1998-10-09 17:16 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1998-10-03 15:30 UTC (permalink / raw)
  To: Zsh hackers list

Here's the bare bones patch for the bug that if a directory is both in
$cdpath and $path you can't autocd to a subdirectory of it because
that's hashed as a command.

It turns out that there's no major problem if a command to be executed
is in the $path first as a directory, then as a command: the command
is hashed incorrectly (as `hash' shows), but the exec is retried and
works.  Also, which/whence does a more sophisticated search and finds
the true command.

(What's happening is zsh tries to exec the hashed command, and if the
exec fails, only then does the command get searched for.  I toyed for
a moment with the idea of doing without command hashing, but there are
almost certainly too many ramifications.)

Anyway, at the moment it looks to me like nothing other than the full
stat() horror would be a really worthwhile improvement on the
following.

*** Src/exec.c.hc	Mon Sep 28 10:37:43 1998
--- Src/exec.c	Mon Sep 28 11:37:19 1998
***************
*** 524,529 ****
--- 524,542 ----
  
  /**/
  int
+ isreallycom(Cmdnam cn)
+ {
+     char fullnam[MAXCMDLEN];
+     struct stat statbuf;
+ 
+     strcpy(fullnam, cn->u.name ? *(cn->u.name) : "");
+     strcat(fullnam, "/");
+     strcat(fullnam, cn->nam);
+     return iscom(fullnam);
+ }
+ 
+ /**/
+ int
  isrelative(char *s)
  {
      if (*s != '/')
***************
*** 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)

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


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

end of thread, other threads:[~1998-10-14 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-03 15:30 PATCH: 3.1.4: autocd to directory in $PATH Peter Stephenson
1998-10-09 17:16 ` Bart Schaefer
1998-10-12 12:18   ` PATCH: 3.1.4: autocd to directory in $PATH (2) Peter Stephenson
1998-10-14 19:07     ` PATCH: " 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).