make the code to exec simple commands also available for mksh_small

This commit is contained in:
tg 2014-01-11 16:26:28 +00:00
parent c8188de88b
commit c1c0b997fe
3 changed files with 4 additions and 17 deletions

6
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.128 2014/01/05 21:57:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.129 2014/01/11 16:26:27 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -604,19 +604,15 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
/* go on, use the builtin */
break;
#endif
#if !defined(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));
}
#if !defined(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;

9
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.275 2014/01/05 21:57:26 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.276 2014/01/11 16:26:28 tg Exp $");
extern char **environ;
@ -483,7 +483,6 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
s = pushs(SSTRINGCMDLINE, ATEMP);
if (!(s->start = s->str = argv[argi++]))
errorf("%s %s", "-c", "requires an argument");
#if !defined(MKSH_SMALL)
while (*s->str) {
if (*s->str != ' ' && ctype(*s->str, C_QUOTE))
break;
@ -492,7 +491,6 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
if (!*s->str)
s->flags |= SF_MAYEXEC;
s->str = s->start;
#endif
#ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT
/* compatibility to MidnightBSD 0.1 /bin/sh (kludge) */
if (Flag(FSH) && argv[argi] && !strcmp(argv[argi], "--"))
@ -873,11 +871,8 @@ shell(Source * volatile s, volatile bool toplevel)
unwind(LEXIT);
break;
}
}
#if !defined(MKSH_SMALL)
else if ((s->flags & SF_MAYEXEC) && t->type == TCOM)
} else if ((s->flags & SF_MAYEXEC) && t->type == TCOM)
t->u.evalflags |= DOTCOMEXEC;
#endif
if (!Flag(FNOEXEC) || (s->flags & SF_TTY))
exstat = execute(t, 0, NULL) & 0xFF;

6
sh.h
View File

@ -169,7 +169,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.682 2014/01/05 21:57:28 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.683 2014/01/11 16:26:28 tg Exp $");
#endif
#define MKSH_VERSION "R49 2014/01/05"
@ -1385,9 +1385,7 @@ struct ioword {
#define DOTEMP BIT(8) /* dito: in word part of ${..[%#=?]..} */
#define DOVACHECK BIT(9) /* var assign check (for typeset, set, etc) */
#define DOMARKDIRS BIT(10) /* force markdirs behaviour */
#if !defined(MKSH_SMALL)
#define DOTCOMEXEC BIT(11) /* not an eval flag, used by sh -c hack */
#endif
/*
* The arguments of [[ .. ]] expressions are kept in t->args[] and flags
@ -1531,9 +1529,7 @@ struct source {
#define SF_ALIASEND BIT(2) /* faking space at end of alias */
#define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */
#define SF_HASALIAS BIT(4) /* u.tblp valid (SALIAS, SEOF) */
#if !defined(MKSH_SMALL)
#define SF_MAYEXEC BIT(5) /* special sh -c optimisation hack */
#endif
typedef union {
int i;