EXPERIMENTAL optimisation for “sh -c 'foo'” to equal “sh -c 'exit foo'” iff
several conditions are met as outlined below; for more background, refer to http://www.FreeBSD.org/cgi/query-pr.cgi?pr=113860 We don’t yet optimise 「% sh -c '{ echo a; sleep 10;}&'; sleep 1; ps T」 so the FreeBSD® sh approach cannot work for us, but scanning the “sh -c” argu‐ ment for disallowed characters and, if not, setting a flag that enables the shell to exec the tree when parsed as TCOM *and not c_trap()* was possible. Disallowed characters are currently C_QUOTE except space, that is: Tab Newline " # $ & ' ( ) * ; < = > ? [ \ ] ` | This should catch all cases of magic, variables, subshells, pipelines, etc.
This commit is contained in:
11
exec.c
11
exec.c
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.101 2012/10/03 17:24:18 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.102 2012/10/21 21:26:39 tg Exp $");
|
||||
|
||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||
@@ -604,11 +604,20 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
||||
else
|
||||
/* go on, use the builtin */
|
||||
break;
|
||||
#endif
|
||||
#ifndef MKSH_SMALL
|
||||
} else if (tp->val.f == c_trap) {
|
||||
t->u.evalflags &= ~DOTCOMEXEC;
|
||||
break;
|
||||
#endif
|
||||
} else
|
||||
break;
|
||||
tp = findcom(ap[0], fcflags & (FC_BI|FC_FUNC));
|
||||
}
|
||||
#ifndef MKSH_SMALL
|
||||
if (t->u.evalflags & DOTCOMEXEC)
|
||||
flags |= XEXEC;
|
||||
#endif
|
||||
l_expand = e->loc;
|
||||
if (keepasn_ok && (!ap[0] || (tp && (tp->flag & KEEPASN))))
|
||||
type_flags = 0;
|
||||
|
Reference in New Issue
Block a user