zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@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	[thread overview]
Message-ID: <9810031530.AA20041@ibmth.df.unipi.it> (raw)

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


             reply	other threads:[~1998-10-03 15:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-03 15:30 Peter Stephenson [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9810031530.AA20041@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).