* change EXECSHELL to /bin/sh (we can override it via environment anyway,

and this is a sensible choice instead of ourselves)
* move this stuff from sh.h into exec.c where it belongs
* simplify set -o stuff

saves 8 bytes
This commit is contained in:
tg 2006-11-10 01:44:40 +00:00
parent cd9202835c
commit c60dbdc6cb
3 changed files with 10 additions and 16 deletions

7
exec.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.16 2006/08/01 13:43:26 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.17 2006/11/10 01:44:39 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, char **,
int volatile);
@ -665,13 +665,14 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
static void
scriptexec(struct op *tp, char **ap)
{
static char execshell[] = "/bin/sh";
char *sh;
sh = str_val(global(EXECSHELL_STR));
sh = str_val(global("EXECSHELL"));
if (sh && *sh)
sh = search(sh, path, X_OK, NULL);
if (!sh || !*sh)
sh = strdup(EXECSHELL);
sh = execshell;
*tp->args-- = tp->str;
*tp->args = sh;

14
misc.c
View File

@ -3,7 +3,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.24 2006/11/10 01:19:17 tg Exp $\t"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.25 2006/11/10 01:44:39 tg Exp $\t"
MKSH_SH_H_ID);
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
@ -149,10 +149,7 @@ option(const char *n)
struct options_info {
int opt_width;
struct {
const char *name;
int flag;
} opts[NELEM(options)];
int opts[NELEM(options)];
};
static char *options_fmt_entry(void *arg, int i, char *buf, int buflen);
@ -165,8 +162,8 @@ options_fmt_entry(void *arg, int i, char *buf, int buflen)
struct options_info *oi = (struct options_info *) arg;
shf_snprintf(buf, buflen, "%-*s %s",
oi->opt_width, oi->opts[i].name,
Flag(oi->opts[i].flag) ? "on" : "off");
oi->opt_width, options[oi->opts[i]].name,
Flag(oi->opts[i]) ? "on" : "off");
return buf;
}
@ -185,8 +182,7 @@ printoptions(int verbose)
for (i = n = oi.opt_width = 0; i < NELEM(options); i++)
if (options[i].name) {
len = strlen(options[i].name);
oi.opts[n].name = options[i].name;
oi.opts[n++].flag = i;
oi.opts[n++] = i;
if (len > oi.opt_width)
oi.opt_width = len;
}

5
sh.h
View File

@ -8,7 +8,7 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.70 2006/11/10 01:25:22 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.71 2006/11/10 01:44:40 tg Exp $"
#define MKSH_VERSION "R29 2006/11/10"
#if HAVE_SYS_PARAM_H
@ -135,9 +135,6 @@ extern int __cdecl setegid(gid_t);
# define EXTERN_DEFINED
#endif
#define EXECSHELL "/bin/mksh"
#define EXECSHELL_STR "EXECSHELL"
#define NELEM(a) (sizeof (a) / sizeof ((a)[0]))
#define sizeofN(typ, n) (sizeof (typ) * (n))
#define BIT(i) (1 << (i)) /* define bit in flag */