diff --git a/check.t b/check.t index 8ff54a4..e5a8a8c 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.794 2017/07/26 23:02:23 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.795 2017/08/07 21:16:29 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -30,7 +30,7 @@ # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date expected-stdout: - @(#)MIRBSD KSH R55 2017/07/26 + @(#)MIRBSD KSH R56 2017/08/07 description: Check base version of full shell stdin: @@ -39,7 +39,7 @@ name: KSH_VERSION category: !shell:legacy-yes --- expected-stdout: - @(#)LEGACY KSH R55 2017/07/26 + @(#)LEGACY KSH R56 2017/08/07 description: Check base version of legacy shell stdin: @@ -7046,6 +7046,48 @@ expected-stdout: y1- x2-3- z1- --- +name: exec-modern-korn-shell +description: + Check that exec can execute any command that makes it + through syntax and parser +stdin: + print '#!'"$__progname"'\necho tf' >lq + chmod +x lq + PATH=$PWD + exec 2>&1 + foo() { print two; } + print =1 + (exec print one) + print =2 + (exec foo) + print =3 + (exec ls) + print =4 + (exec lq) +expected-stdout-pattern: + /=1\none\n=2\ntwo\n=3\n.*: ls: not found\n=4\ntf\n/ +--- +name: exec-ksh88 +description: + Check that exec only executes after a PATH search +arguments: !-o!posix! +stdin: + print '#!'"$__progname"'\necho tf' >lq + chmod +x lq + PATH=$PWD + exec 2>&1 + foo() { print two; } + print =1 + (exec print one) + print =2 + (exec foo) + print =3 + (exec ls) + print =4 + (exec lq) +expected-stdout-pattern: + /=1\n.*: print: not found\n=2\n.*: foo: not found\n=3\n.*: ls: not found\n=4\ntf\n/ +--- name: xxx-what-do-you-call-this-1 stdin: echo "${foo:-"a"}*" diff --git a/exec.c b/exec.c index dd0565f..56a42f6 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.198 2017/04/29 22:04:28 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.199 2017/08/07 21:16:31 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" @@ -554,6 +554,9 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap, } ap += builtin_opt.optind; flags |= XEXEC; + /* POSuX demands ksh88-like behaviour here */ + if (Flag(FPOSIX)) + fcflags = FC_PATH; } else if (tp->val.f == c_command) { bool saw_p = false; diff --git a/mksh.1 b/mksh.1 index 4ae26e6..b805775 100644 --- a/mksh.1 +++ b/mksh.1 @@ -1,4 +1,4 @@ -.\" $MirOS: src/bin/mksh/mksh.1,v 1.448 2017/08/07 20:49:42 tg Exp $ +.\" $MirOS: src/bin/mksh/mksh.1,v 1.449 2017/08/07 21:16:32 tg Exp $ .\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $ .\"- .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, @@ -5387,6 +5387,11 @@ only lists signal names, all in one line. .Ic getopts does not accept options with a leading .Ql + . +.It +.Ic exec +skips builtins, functions and other commands and uses a +.Ev PATH +search to determine the utility to execute. .El .Ss SH mode Compatibility mode; intended for use with legacy scripts that @@ -6691,7 +6696,7 @@ for the in-memory portion of the history is slow, should use .Xr memmove 3 . .Pp This document attempts to describe -.Nm mksh\ R55 +.Nm mksh\ R56 and up, .\" with vendor patches from insert-your-name-here, compiled without any options impacting functionality, such as