• let mksh “set -x” print whole TCOM trees
• plug some memory leaks in debug (“set -x”) and warning paths while here • one from Florian (friend of Natureshadow) for WTF
This commit is contained in:
6
Build.sh
6
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.624 2013/03/05 15:41:39 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.625 2013/03/24 00:56:17 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013
|
# 2011, 2012, 2013
|
||||||
@ -1532,7 +1532,7 @@ else
|
|||||||
#define EXTERN
|
#define EXTERN
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.624 2013/03/05 15:41:39 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.625 2013/03/24 00:56:17 tg Exp $");
|
||||||
int main(void) { printf("Hello, World!\n"); return (0); }
|
int main(void) { printf("Hello, World!\n"); return (0); }
|
||||||
EOF
|
EOF
|
||||||
case $cm in
|
case $cm in
|
||||||
@ -2120,7 +2120,7 @@ addsrcs USE_PRINTF_BUILTIN printf.c
|
|||||||
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
|
||||||
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
|
||||||
test -n "$LDSTATIC" && add_cppflags -DMKSH_OPTSTATIC
|
test -n "$LDSTATIC" && add_cppflags -DMKSH_OPTSTATIC
|
||||||
add_cppflags -DMKSH_BUILD_R=441
|
add_cppflags -DMKSH_BUILD_R=449
|
||||||
|
|
||||||
$e $bi$me: Finished configuration testing, now producing output.$ao
|
$e $bi$me: Finished configuration testing, now producing output.$ao
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/Makefile,v 1.114 2013/03/05 15:41:40 tg Exp $
|
# $MirOS: src/bin/mksh/Makefile,v 1.115 2013/03/24 00:56:19 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013
|
# 2011, 2012, 2013
|
||||||
@ -55,7 +55,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \
|
|||||||
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
-DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
|
||||||
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
|
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
|
||||||
-DHAVE_PERSISTENT_HISTORY=1 -DHAVE_SILENT_IDIVWRAPV=0 \
|
-DHAVE_PERSISTENT_HISTORY=1 -DHAVE_SILENT_IDIVWRAPV=0 \
|
||||||
-DMKSH_BUILD_R=441
|
-DMKSH_BUILD_R=449
|
||||||
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
|
||||||
COPTS+= -std=c99 -Wall
|
COPTS+= -std=c99 -Wall
|
||||||
.endif
|
.endif
|
||||||
|
6
check.t
6
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.599 2013/02/24 14:22:41 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.600 2013/03/24 00:56:19 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -29,7 +29,7 @@
|
|||||||
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R44 2013/02/24
|
@(#)MIRBSD KSH R44 2013/03/23
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -38,7 +38,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R44 2013/02/24
|
@(#)LEGACY KSH R44 2013/03/23
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
32
exec.c
32
exec.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.116 2013/02/17 05:40:15 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.117 2013/03/24 00:56:22 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||||
@ -138,12 +138,10 @@ execute(struct op * volatile t,
|
|||||||
/* Allow option parsing (bizarre, but POSIX) */
|
/* Allow option parsing (bizarre, but POSIX) */
|
||||||
timex_hook(t, &up);
|
timex_hook(t, &up);
|
||||||
ap = (const char **)up;
|
ap = (const char **)up;
|
||||||
if (Flag(FXTRACE) && ap[0]) {
|
if (Flag(FXTRACE)) {
|
||||||
shf_puts(substitute(str_val(global("PS4")), 0),
|
shf_puts(substitute(str_val(global("PS4")), 0),
|
||||||
shl_out);
|
shl_out);
|
||||||
for (i = 0; ap[i]; i++)
|
fptreef(shl_out, 0, "%T\n", t);
|
||||||
shf_fprintf(shl_out, "%s%c", ap[i],
|
|
||||||
ap[i + 1] ? ' ' : '\n');
|
|
||||||
shf_flush(shl_out);
|
shf_flush(shl_out);
|
||||||
}
|
}
|
||||||
if (ap[0])
|
if (ap[0])
|
||||||
@ -645,16 +643,6 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
cp = evalstr(t->vars[i], DOASNTILDE);
|
cp = evalstr(t->vars[i], DOASNTILDE);
|
||||||
e->loc = l_assign;
|
e->loc = l_assign;
|
||||||
/* but assign in there as usual */
|
/* but assign in there as usual */
|
||||||
|
|
||||||
if (Flag(FXTRACE)) {
|
|
||||||
if (i == 0)
|
|
||||||
shf_puts(substitute(str_val(global("PS4")), 0),
|
|
||||||
shl_out);
|
|
||||||
shf_fprintf(shl_out, "%s%c", cp,
|
|
||||||
t->vars[i + 1] ? ' ' : '\n');
|
|
||||||
if (!t->vars[i + 1])
|
|
||||||
shf_flush(shl_out);
|
|
||||||
}
|
|
||||||
typeset(cp, type_flags, 0, 0, 0);
|
typeset(cp, type_flags, 0, 0, 0);
|
||||||
if (bourne_function_call && !(type_flags & EXPORT))
|
if (bourne_function_call && !(type_flags & EXPORT))
|
||||||
typeset(cp, LOCAL|LOCAL_COPY|EXPORT, 0, 0, 0);
|
typeset(cp, LOCAL|LOCAL_COPY|EXPORT, 0, 0, 0);
|
||||||
@ -1298,11 +1286,6 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
|||||||
iotmp.name = (iotype == IOHERE) ? NULL : cp;
|
iotmp.name = (iotype == IOHERE) ? NULL : cp;
|
||||||
iotmp.flag |= IONAMEXP;
|
iotmp.flag |= IONAMEXP;
|
||||||
|
|
||||||
if (Flag(FXTRACE))
|
|
||||||
shellf("%s%s\n",
|
|
||||||
substitute(str_val(global("PS4")), 0),
|
|
||||||
snptreef(NULL, 32, "%R", &iotmp));
|
|
||||||
|
|
||||||
switch (iotype) {
|
switch (iotype) {
|
||||||
case IOREAD:
|
case IOREAD:
|
||||||
flags = O_RDONLY;
|
flags = O_RDONLY;
|
||||||
@ -1345,8 +1328,11 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
|||||||
} else if ((u = check_fd(cp,
|
} else if ((u = check_fd(cp,
|
||||||
X_OK | ((iop->flag & IORDUP) ? R_OK : W_OK),
|
X_OK | ((iop->flag & IORDUP) ? R_OK : W_OK),
|
||||||
&emsg)) < 0) {
|
&emsg)) < 0) {
|
||||||
|
char *sp;
|
||||||
|
|
||||||
warningf(true, "%s: %s",
|
warningf(true, "%s: %s",
|
||||||
snptreef(NULL, 32, "%R", &iotmp), emsg);
|
(sp = snptreef(NULL, 32, "%R", &iotmp)), emsg);
|
||||||
|
afree(sp, ATEMP);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (u == iop->unit)
|
if (u == iop->unit)
|
||||||
@ -1395,12 +1381,14 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
|||||||
else if (u != iop->unit) {
|
else if (u != iop->unit) {
|
||||||
if (ksh_dup2(u, iop->unit, true) < 0) {
|
if (ksh_dup2(u, iop->unit, true) < 0) {
|
||||||
int eno;
|
int eno;
|
||||||
|
char *sp;
|
||||||
|
|
||||||
eno = errno;
|
eno = errno;
|
||||||
warningf(true, "%s %s %s",
|
warningf(true, "%s %s %s",
|
||||||
"can't finish (dup) redirection",
|
"can't finish (dup) redirection",
|
||||||
snptreef(NULL, 32, "%R", &iotmp),
|
(sp = snptreef(NULL, 32, "%R", &iotmp)),
|
||||||
cstrerror(eno));
|
cstrerror(eno));
|
||||||
|
afree(sp, ATEMP);
|
||||||
if (iotype != IODUP)
|
if (iotype != IODUP)
|
||||||
close(u);
|
close(u);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
11
mksh.1
11
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.305 2013/02/19 18:45:20 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.306 2013/03/24 00:56:23 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.145 2013/01/17 21:20:25 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.145 2013/01/17 21:20:25 jmc Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -74,7 +74,7 @@
|
|||||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||||
.\" use our own definition. And .Dd must come *first*, always.
|
.\" use our own definition. And .Dd must come *first*, always.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: February 19 2013 $
|
.Dd $Mdocdate: March 24 2013 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use, and do other -mdoc setup.
|
.\" Check which macro package we use, and do other -mdoc setup.
|
||||||
.\"
|
.\"
|
||||||
@ -2037,6 +2037,9 @@ Parameter, command, and arithmetic substitutions are performed
|
|||||||
before it is printed.
|
before it is printed.
|
||||||
The default is
|
The default is
|
||||||
.Sq +\ \& .
|
.Sq +\ \& .
|
||||||
|
You may want to set it to
|
||||||
|
.Sq \&[$EPOCHREALTIME]\ \&
|
||||||
|
instead, to include timestamps.
|
||||||
.It Ev PWD
|
.It Ev PWD
|
||||||
The current working directory.
|
The current working directory.
|
||||||
May be unset or
|
May be unset or
|
||||||
@ -4097,7 +4100,7 @@ Mark directories with a trailing
|
|||||||
.Ql /
|
.Ql /
|
||||||
during file name generation.
|
during file name generation.
|
||||||
.It Fl x \*(Ba Fl o Ic xtrace
|
.It Fl x \*(Ba Fl o Ic xtrace
|
||||||
Print commands and parameter assignments when they are executed, preceded by
|
Print command trees when they are executed, preceded by
|
||||||
the value of
|
the value of
|
||||||
.Ev PS4 .
|
.Ev PS4 .
|
||||||
.It Fl o Ic bgnice
|
.It Fl o Ic bgnice
|
||||||
@ -6335,7 +6338,7 @@ $ /bin/sleep 666 && echo fubar
|
|||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
This document attempts to describe
|
This document attempts to describe
|
||||||
.Nm mksh\ R43
|
.Nm mksh\ R44
|
||||||
and up,
|
and up,
|
||||||
compiled without any options impacting functionality, such as
|
compiled without any options impacting functionality, such as
|
||||||
.Dv MKSH_SMALL ,
|
.Dv MKSH_SMALL ,
|
||||||
|
6
sh.h
6
sh.h
@ -164,9 +164,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.642 2013/03/05 15:41:41 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.643 2013/03/24 00:56:25 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R44 2013/02/24"
|
#define MKSH_VERSION "R44 2013/03/23"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -511,7 +511,7 @@ char *ucstrstr(char *, const char *);
|
|||||||
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
#define mkssert(e) do { } while (/* CONSTCOND */ 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 441)
|
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 449)
|
||||||
#error Must run Build.sh to compile this.
|
#error Must run Build.sh to compile this.
|
||||||
int
|
int
|
||||||
im_sorry_dave(void)
|
im_sorry_dave(void)
|
||||||
|
20
tree.c
20
tree.c
@ -23,12 +23,12 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.67 2012/12/04 01:10:35 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.68 2013/03/24 00:56:27 tg Exp $");
|
||||||
|
|
||||||
#define INDENT 8
|
#define INDENT 8
|
||||||
|
|
||||||
static void ptree(struct op *, int, struct shf *);
|
static void ptree(struct op *, int, struct shf *);
|
||||||
static void pioact(struct shf *, int, struct ioword *);
|
static void pioact(struct shf *, struct ioword *);
|
||||||
static const char *wdvarput(struct shf *, const char *, int, int);
|
static const char *wdvarput(struct shf *, const char *, int, int);
|
||||||
static void vfptreef(struct shf *, int, const char *, va_list);
|
static void vfptreef(struct shf *, int, const char *, va_list);
|
||||||
static struct ioword **iocopy(struct ioword **, Area *);
|
static struct ioword **iocopy(struct ioword **, Area *);
|
||||||
@ -214,7 +214,7 @@ ptree(struct op *t, int indent, struct shf *shf)
|
|||||||
bool need_nl = false;
|
bool need_nl = false;
|
||||||
|
|
||||||
while (*ioact != NULL)
|
while (*ioact != NULL)
|
||||||
pioact(shf, indent, *ioact++);
|
pioact(shf, *ioact++);
|
||||||
/* Print here documents after everything else... */
|
/* Print here documents after everything else... */
|
||||||
ioact = t->ioact;
|
ioact = t->ioact;
|
||||||
while (*ioact != NULL) {
|
while (*ioact != NULL) {
|
||||||
@ -244,7 +244,7 @@ ptree(struct op *t, int indent, struct shf *shf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pioact(struct shf *shf, int indent, struct ioword *iop)
|
pioact(struct shf *shf, struct ioword *iop)
|
||||||
{
|
{
|
||||||
int flag = iop->flag;
|
int flag = iop->flag;
|
||||||
int type = flag & IOTYPE;
|
int type = flag & IOTYPE;
|
||||||
@ -283,9 +283,13 @@ pioact(struct shf *shf, int indent, struct ioword *iop)
|
|||||||
wdvarput(shf, iop->delim, 0, WDS_TPUTS);
|
wdvarput(shf, iop->delim, 0, WDS_TPUTS);
|
||||||
if (iop->flag & IOHERESTR)
|
if (iop->flag & IOHERESTR)
|
||||||
shf_putc(' ', shf);
|
shf_putc(' ', shf);
|
||||||
} else if (iop->name)
|
} else if (iop->name) {
|
||||||
fptreef(shf, indent, (iop->flag & IONAMEXP) ? "%s " : "%S ",
|
if (iop->flag & IONAMEXP)
|
||||||
iop->name);
|
print_value_quoted(shf, iop->name);
|
||||||
|
else
|
||||||
|
wdvarput(shf, iop->name, 0, WDS_TPUTS);
|
||||||
|
shf_putc(' ', shf);
|
||||||
|
}
|
||||||
prevent_semicolon = false;
|
prevent_semicolon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +489,7 @@ vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
|
|||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
/* I/O redirection */
|
/* I/O redirection */
|
||||||
pioact(shf, indent, va_arg(va, struct ioword *));
|
pioact(shf, va_arg(va, struct ioword *));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
shf_putc(c, shf);
|
shf_putc(c, shf);
|
||||||
|
Reference in New Issue
Block a user