summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-02-11 21:06:45 +0000
committerjilles <jilles@FreeBSD.org>2012-02-11 21:06:45 +0000
commit0458d57ea3cd173f7a4e71d67ee628f844dbdd70 (patch)
tree852790d9d43354df7d798f44b33557a07ff9b181 /bin/sh
parent959ca16023aae7c8432edca09966fbccd16d5a90 (diff)
downloadFreeBSD-src-0458d57ea3cd173f7a4e71d67ee628f844dbdd70.zip
FreeBSD-src-0458d57ea3cd173f7a4e71d67ee628f844dbdd70.tar.gz
sh: Make 'hash' return 1 if at least one utility is not found.
Reported by: lme
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/exec.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index 82cb3ac..f2e4c1d 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -231,7 +231,9 @@ hashcmd(int argc __unused, char **argv __unused)
int verbose;
struct cmdentry entry;
char *name;
+ int errors;
+ errors = 0;
verbose = 0;
while ((c = nextopt("rv")) != '\0') {
if (c == 'r') {
@@ -254,19 +256,21 @@ hashcmd(int argc __unused, char **argv __unused)
&& cmdp->cmdtype == CMDNORMAL)
delete_cmd_entry();
find_command(name, &entry, DO_ERR, pathval());
- if (verbose) {
- if (entry.cmdtype != CMDUNKNOWN) { /* if no error msg */
- cmdp = cmdlookup(name, 0);
- if (cmdp != NULL)
- printentry(cmdp, verbose);
- else
- outfmt(out2, "%s: not found\n", name);
+ if (entry.cmdtype == CMDUNKNOWN)
+ errors = 1;
+ else if (verbose) {
+ cmdp = cmdlookup(name, 0);
+ if (cmdp != NULL)
+ printentry(cmdp, verbose);
+ else {
+ outfmt(out2, "%s: not found\n", name);
+ errors = 1;
}
flushall();
}
argptr++;
}
- return 0;
+ return errors;
}
OpenPOWER on IntegriCloud