Date: Sat, 11 Feb 2012 21:06:45 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r231535 - in head: bin/sh tools/regression/bin/sh/builtins Message-ID: <201202112106.q1BL6jMf048146@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sat Feb 11 21:06:45 2012 New Revision: 231535 URL: http://svn.freebsd.org/changeset/base/231535 Log: sh: Make 'hash' return 1 if at least one utility is not found. Reported by: lme Added: head/tools/regression/bin/sh/builtins/hash4.0 (contents, props changed) Modified: head/bin/sh/exec.c Modified: head/bin/sh/exec.c ============================================================================== --- head/bin/sh/exec.c Sat Feb 11 20:47:16 2012 (r231534) +++ head/bin/sh/exec.c Sat Feb 11 21:06:45 2012 (r231535) @@ -231,7 +231,9 @@ hashcmd(int argc __unused, char **argv _ 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 _ && 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; } Added: head/tools/regression/bin/sh/builtins/hash4.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/hash4.0 Sat Feb 11 21:06:45 2012 (r231535) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +exec 3>&1 +m=`hash nosuchtool 2>&1 >&3` +r=$? +[ "$r" != 0 ] && [ -n "$m" ]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202112106.q1BL6jMf048146>