From 42bbf4dc0613a5ee178a72ebfc36659d832f7cb8 Mon Sep 17 00:00:00 2001 From: cracauer Date: Wed, 16 Aug 2000 12:08:02 +0000 Subject: Fix type builtin for absolute paths and relative paths with directory names in them. Also use a colon in the answer of `type` everytime the questioned item is not usable. PR: bin/20567 --- bin/sh/exec.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 67a858b..714ac36 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -891,14 +891,21 @@ typecmd(argc, argv) switch (entry.cmdtype) { case CMDNORMAL: { - int j = entry.u.index; - char *path = pathval(), *name; - do { - name = padvance(&path, argv[i]); - stunalloc(name); - } while (--j >= 0); - out1fmt(" is%s %s\n", - cmdp ? " a tracked alias for" : "", name); + if (strchr(argv[i], '/') == NULL) { + char *path = pathval(), *name; + int j = entry.u.index; + do { + name = padvance(&path, argv[i]); + stunalloc(name); + } while (--j >= 0); + out1fmt(" is%s %s\n", + cmdp ? " a tracked alias for" : "", name); + } else { + if (access(argv[i], X_OK) == 0) + out1fmt(" is %s\n", argv[i]); + else + out1fmt(": %s\n", strerror(errno)); + } break; } case CMDFUNCTION: @@ -910,7 +917,7 @@ typecmd(argc, argv) break; default: - out1str(" not found\n"); + out1str(": not found\n"); error |= 127; break; } -- cgit v1.1