fix which /bin/csh returning .//bin/csh
authorChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Wed, 24 May 1995 06:39:41 +0000 (22:39 -0800)
committerChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Wed, 24 May 1995 06:39:41 +0000 (22:39 -0800)
(adapted changes from the tcsh source)

SCCS-vsn: bin/csh/exec.c 8.3

usr/src/bin/csh/exec.c

index 40bbefb..959ec18 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)exec.c     8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)exec.c     8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -630,7 +630,7 @@ tellmewhat(lex)
     register struct biltins *bptr;
     register struct wordent *sp = lex->next;
     bool    aliased = 0;
     register struct biltins *bptr;
     register struct wordent *sp = lex->next;
     bool    aliased = 0;
-    Char   *s0, *s1, *s2;
+    Char   *s0, *s1, *s2, *cmd;
     Char    qc;
 
     if (adrof1(sp->word, &aliases)) {
     Char    qc;
 
     if (adrof1(sp->word, &aliases)) {
@@ -677,6 +677,8 @@ tellmewhat(lex)
        }
     }
 
        }
     }
 
+    sp->word = cmd = globone(sp->word, G_IGNORE);
+
     if ((i = iscommand(strip(sp->word))) != 0) {
        register Char **pv;
        register struct varent *v;
     if ((i = iscommand(strip(sp->word))) != 0) {
        register Char **pv;
        register struct varent *v;
@@ -691,10 +693,15 @@ tellmewhat(lex)
        while (--i)
            pv++;
        if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
        while (--i)
            pv++;
        if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
-           sp->word = Strspl(STRdotsl, sp->word);
-           prlex(cshout, lex);
-           xfree((ptr_t) sp->word);
+           if (!slash) {
+               sp->word = Strspl(STRdotsl, sp->word);
+               prlex(cshout, lex);
+               xfree((ptr_t) sp->word);
+           }
+           else
+               prlex(cshout, lex);
            sp->word = s0;      /* we save and then restore this */
            sp->word = s0;      /* we save and then restore this */
+           xfree((ptr_t) cmd);
            return;
        }
        s1 = Strspl(*pv, STRslash);
            return;
        }
        s1 = Strspl(*pv, STRslash);
@@ -709,4 +716,5 @@ tellmewhat(lex)
        (void) fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word));
     }
     sp->word = s0;             /* we save and then restore this */
        (void) fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word));
     }
     sp->word = s0;             /* we save and then restore this */
+    xfree((ptr_t) cmd);
 }
 }