diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-10-06 22:00:14 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-10-06 22:00:14 +0000 |
commit | 640b70e414ec45099bd3a63268b56013fb640004 (patch) | |
tree | 1f4527ca00ce718b312864a2fb301567490f5fa0 /bin/sh | |
parent | e6b112e27422734806e073dc5c1fd6c516c7f687 (diff) | |
download | src-640b70e414ec45099bd3a63268b56013fb640004.tar.gz src-640b70e414ec45099bd3a63268b56013fb640004.zip |
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
Notes
Notes:
svn path=/head/; revision=197820
Diffstat (limited to 'bin/sh')
-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 7978b84f051e..5ba244d76e41 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 810782166a9f..f9d3c221a3a5 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: |