diff options
-rw-r--r-- | bin/sh/eval.c | 9 | ||||
-rw-r--r-- | bin/sh/exec.c | 1 | ||||
-rw-r--r-- | tools/regression/bin/sh/execution/unknown1.0 | 29 |
3 files changed, 32 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: diff --git a/tools/regression/bin/sh/execution/unknown1.0 b/tools/regression/bin/sh/execution/unknown1.0 new file mode 100644 index 000000000000..45f541e6eeea --- /dev/null +++ b/tools/regression/bin/sh/execution/unknown1.0 @@ -0,0 +1,29 @@ +# $FreeBSD$ + +nosuchtool 2>/dev/null +[ $? -ne 127 ] && exit 1 +/var/empty/nosuchtool 2>/dev/null +[ $? -ne 127 ] && exit 1 +(nosuchtool) 2>/dev/null +[ $? -ne 127 ] && exit 1 +(/var/empty/nosuchtool) 2>/dev/null +[ $? -ne 127 ] && exit 1 +/ 2>/dev/null +[ $? -ne 126 ] && exit 1 +PATH=/usr bin 2>/dev/null +[ $? -ne 126 ] && exit 1 + +dummy=$(nosuchtool 2>/dev/null) +[ $? -ne 127 ] && exit 1 +dummy=$(/var/empty/nosuchtool 2>/dev/null) +[ $? -ne 127 ] && exit 1 +dummy=$( (nosuchtool) 2>/dev/null) +[ $? -ne 127 ] && exit 1 +dummy=$( (/var/empty/nosuchtool) 2>/dev/null) +[ $? -ne 127 ] && exit 1 +dummy=$(/ 2>/dev/null) +[ $? -ne 126 ] && exit 1 +dummy=$(PATH=/usr bin 2>/dev/null) +[ $? -ne 126 ] && exit 1 + +exit 0 |