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
This commit is contained in:
Martin Cracauer 2000-08-16 12:08:02 +00:00
parent 087a20b80a
commit d753a42598
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64704

View File

@ -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;
}