diff options
author | jilles <jilles@FreeBSD.org> | 2009-10-06 22:00:14 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2009-10-06 22:00:14 +0000 |
commit | fab15b104fd8b8032114bca20d5768c8af19156d (patch) | |
tree | 1f4527ca00ce718b312864a2fb301567490f5fa0 /bin | |
parent | 3665e257c1063729cb55852b1e0686ab8301f7d1 (diff) | |
download | FreeBSD-src-fab15b104fd8b8032114bca20d5768c8af19156d.zip FreeBSD-src-fab15b104fd8b8032114bca20d5768c8af19156d.tar.gz |
sh: Send the "xyz: not found" message to redirected fd 2.
This also fixes that trying to execute a non-regular file with a command
name without '/' returns 127 instead of 126.
The fix is rather simplistic: treat CMDUNKNOWN as if the command were found
as an external program. The resulting fork is a bit wasteful but executing
unknown commands should not be very frequent.
PR: bin/137659
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/eval.c | 9 | ||||
-rw-r--r-- | bin/sh/exec.c | 1 |
2 files changed, 3 insertions, 7 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 7978b84..5ba244d 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -713,12 +713,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) do_clearcmdentry = 1; } - find_command(argv[0], &cmdentry, 1, path); - if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */ - exitstatus = 127; - flushout(&errout); - return; - } + find_command(argv[0], &cmdentry, 0, path); /* implement the bltin builtin here */ if (cmdentry.cmdtype == CMDBUILTIN && cmdentry.u.index == BLTINCMD) { for (;;) { @@ -740,7 +735,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) /* Fork off a child process if necessary. */ if (cmd->ncmd.backgnd - || (cmdentry.cmdtype == CMDNORMAL + || ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) && ((flags & EV_EXIT) == 0 || have_traps())) || ((flags & EV_BACKCMD) != 0 && (cmdentry.cmdtype != CMDBUILTIN diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 8107821..f9d3c22 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -429,6 +429,7 @@ loop: outfmt(out2, "%s: %s\n", name, strerror(e)); } entry->cmdtype = CMDUNKNOWN; + entry->u.index = 0; return; success: |