@@ -445,8 +445,8 @@ loop:
e = errno;
goto loop;
}
- e = EACCES; /* if we fail, this will be the error */
- if (!S_ISREG(statb.st_mode))
+ e = ENOENT; /* if we fail, this will be the error */
+ if (!S_ISREG(statb.st_mode) || access(fullname, F_OK|X_OK) != 0)
continue;
if (lpathopt) { /* this is a %func directory */
stalloc(len);
@@ -832,6 +832,9 @@ describe_command(out, command, path, verbose)
} while (--j >= 0);
p = stackblock();
}
+ if (access(p, X_OK) != 0) {
+ goto not_found;
+ }
if (verbose) {
outfmt(
out, " is%s %s",
@@ -864,15 +867,18 @@ describe_command(out, command, path, verbose)
break;
default:
- if (verbose) {
- outstr(": not found\n", out);
- }
- return 127;
+ goto not_found;
}
out:
outc('\n', out);
return 0;
+
+not_found:
+ if (verbose) {
+ outstr(": not found\n", out);
+ }
+ return 127;
}
int