diff options
author | jilles <jilles@FreeBSD.org> | 2010-01-03 15:01:38 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-01-03 15:01:38 +0000 |
commit | e314ef3281624dea0d944acf3c131dcd34fdc9ea (patch) | |
tree | 72fdcb06149110f26ca91fd340731d63fcd4eedc /bin/sh/eval.c | |
parent | c9785476fdd9a5a73497c839d02721d23836edf1 (diff) | |
download | FreeBSD-src-e314ef3281624dea0d944acf3c131dcd34fdc9ea.zip FreeBSD-src-e314ef3281624dea0d944acf3c131dcd34fdc9ea.tar.gz |
sh: Send the "not found" message for builtin <cmd> to redirected fd 2.
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r-- | bin/sh/eval.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index f2caafb..30e05b8 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -722,9 +722,10 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) break; if ((cmdentry.u.index = find_builtin(*argv, &cmdentry.special)) < 0) { - out2fmt_flush("%s: not found\n", *argv); - exitstatus = 127; - return; + cmdentry.u.index = BLTINCMD; + argv--; + argc++; + break; } if (cmdentry.u.index != BLTINCMD) break; @@ -944,12 +945,17 @@ prehash(union node *n) */ /* - * No command given, or a bltin command with no arguments. + * No command given, a bltin command with no arguments, or a bltin command + * with an invalid name. */ int -bltincmd(int argc __unused, char **argv __unused) +bltincmd(int argc, char **argv) { + if (argc > 1) { + out2fmt_flush("%s: not found\n", argv[1]); + return 127; + } /* * Preserve exitstatus of a previous possible redirection * as POSIX mandates |