From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26876 invoked from network); 3 Oct 1998 15:46:53 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 3 Oct 1998 15:46:53 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id LAA21548; Sat, 3 Oct 1998 11:39:30 -0400 (EDT) Resent-Date: Sat, 3 Oct 1998 11:39:30 -0400 (EDT) Message-Id: <9810031530.AA20041@ibmth.df.unipi.it> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: PATCH: 3.1.4: autocd to directory in $PATH Date: Sat, 03 Oct 1998 17:30:16 +0200 From: Peter Stephenson Resent-Message-ID: <"SmxZn2.0.aG5.nKa5s"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4404 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Gruppo Teorico, Dipartimento di Fisica Piazza Torricelli 2, 56100 Pisa, Italy