diff options
author | cracauer <cracauer@FreeBSD.org> | 2000-08-16 12:08:02 +0000 |
---|---|---|
committer | cracauer <cracauer@FreeBSD.org> | 2000-08-16 12:08:02 +0000 |
commit | 42bbf4dc0613a5ee178a72ebfc36659d832f7cb8 (patch) | |
tree | 6227f3c54f5c2c7a4b71b9ec01c9a57b2fe915a3 /bin/sh | |
parent | f03fa7361a140ebdac73e27f74b139d0a3d95bf5 (diff) | |
download | FreeBSD-src-42bbf4dc0613a5ee178a72ebfc36659d832f7cb8.zip FreeBSD-src-42bbf4dc0613a5ee178a72ebfc36659d832f7cb8.tar.gz |
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
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/exec.c | 25 |
1 files 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; } |