bring back the backed-out Debian patch if FPOSIX; test programmes fixed:

H4sIAAAAAAACAz1PywrDIBA8m68YgoT20EN7TMixX1F6yGNFIWhRSw2h/95VmuDB2XmsY2oDRVyo
Si1N2uHlMzQK0b8JHaImy4RQwxIITYPiUs4xqcyeGgdfrfumtWX5dMbGSHy0WQgP1PJa49lhdpkV
ynncYSxkOjjxd/V83dmcX9sQtFGRi0zORmO5042HbwnMzlIBqa9lAmfLVBIZ7XqpKBPDnDu+WXpi
wMhnOgQXYvUD+oKHAhUBAAA=

XXX OpenBSD has something different which may DTST or even DTRT (not break
XXX our make(1) wrt <bsd.subdir.mk>), check that
This commit is contained in:
tg 2009-03-16 15:14:23 +00:00
parent 8a77cd5d6e
commit e39c1f860d
3 changed files with 19 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.258 2009/03/15 16:13:37 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.259 2009/03/16 15:14:22 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 $
@ -7,7 +7,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh # http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R36 2009/03/15 @(#)MIRBSD KSH R36 2009/03/16 ~test
description: description:
Check version of shell. Check version of shell.
stdin: stdin:

19
exec.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.48 2008/12/13 17:02:13 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.49 2009/03/16 15:14:23 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, const char **, static int comexec(struct op *, struct tbl *volatile, const char **,
int volatile); int volatile);
@ -25,6 +25,8 @@ execute(struct op *volatile t,
{ {
int i; int i;
volatile int rv = 0; volatile int rv = 0;
/* for FPOSIX only: rv being propagated or newly defined? */
volatile bool rv_prop = false;
int pv[2]; int pv[2];
const char ** volatile ap; const char ** volatile ap;
char ** volatile up; char ** volatile up;
@ -100,6 +102,7 @@ execute(struct op *volatile t,
case TPAREN: case TPAREN:
rv = execute(t->left, flags|XFORK); rv = execute(t->left, flags|XFORK);
rv_prop = true;
break; break;
case TPIPE: case TPIPE:
@ -207,9 +210,10 @@ execute(struct op *volatile t,
case TOR: case TOR:
case TAND: case TAND:
rv = execute(t->left, XERROK); rv = execute(t->left, XERROK);
if (t->right != NULL && (rv == 0) == (t->type == TAND)) if (t->right != NULL && (rv == 0) == (t->type == TAND)) {
rv = execute(t->right, flags & XERROK); rv = execute(t->right, flags & XERROK);
else rv_prop = true;
} else
flags |= XERROK; flags |= XERROK;
break; break;
@ -254,6 +258,7 @@ execute(struct op *volatile t,
} }
} }
rv = 0; /* in case of a continue */ rv = 0; /* in case of a continue */
rv_prop = true;
if (t->type == TFOR) { if (t->type == TFOR) {
while (*ap != NULL) { while (*ap != NULL) {
setstr(global(t->str), *ap++, KSH_UNWIND_ERROR); setstr(global(t->str), *ap++, KSH_UNWIND_ERROR);
@ -263,6 +268,7 @@ execute(struct op *volatile t,
for (;;) { for (;;) {
if (!(cp = do_selectargs(ap, is_first))) { if (!(cp = do_selectargs(ap, is_first))) {
rv = 1; rv = 1;
rv_prop = false;
break; break;
} }
is_first = false; is_first = false;
@ -292,6 +298,7 @@ execute(struct op *volatile t,
rv = 0; /* in case of a continue */ rv = 0; /* in case of a continue */
while ((execute(t->left, XERROK) == 0) == (t->type == TWHILE)) while ((execute(t->left, XERROK) == 0) == (t->type == TWHILE))
rv = execute(t->right, flags & XERROK); rv = execute(t->right, flags & XERROK);
rv_prop = true;
break; break;
case TIF: case TIF:
@ -301,6 +308,7 @@ execute(struct op *volatile t,
rv = execute(t->left, XERROK) == 0 ? rv = execute(t->left, XERROK) == 0 ?
execute(t->right->left, flags & XERROK) : execute(t->right->left, flags & XERROK) :
execute(t->right->right, flags & XERROK); execute(t->right->right, flags & XERROK);
rv_prop = true;
break; break;
case TCASE: case TCASE:
@ -313,10 +321,12 @@ execute(struct op *volatile t,
break; break;
Found: Found:
rv = execute(t->left, flags & XERROK); rv = execute(t->left, flags & XERROK);
rv_prop = true;
break; break;
case TBRACE: case TBRACE:
rv = execute(t->left, flags & XERROK); rv = execute(t->left, flags & XERROK);
rv_prop = true;
break; break;
case TFUNCT: case TFUNCT:
@ -328,6 +338,7 @@ execute(struct op *volatile t,
* (allows "ls -l | time grep foo"). * (allows "ls -l | time grep foo").
*/ */
rv = timex(t, flags & ~XEXEC); rv = timex(t, flags & ~XEXEC);
rv_prop = true;
break; break;
case TEXEC: /* an eval'd TCOM */ case TEXEC: /* an eval'd TCOM */
@ -353,7 +364,7 @@ execute(struct op *volatile t,
quitenv(NULL); /* restores IO */ quitenv(NULL); /* restores IO */
if ((flags&XEXEC)) if ((flags&XEXEC))
unwind(LEXIT); /* exit child */ unwind(LEXIT); /* exit child */
if (rv != 0 && !(flags & XERROK)) { if (rv != 0 && (!Flag(FPOSIX) || !rv_prop) &&!(flags & XERROK)) {
trapsig(SIGERR_); trapsig(SIGERR_);
if (Flag(FERREXIT)) if (Flag(FERREXIT))
unwind(LERROR); unwind(LERROR);

4
sh.h
View File

@ -102,9 +102,9 @@
#define __SCCSID(x) __IDSTRING(sccsid,x) #define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.276 2009/03/15 16:13:40 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.277 2009/03/16 15:14:23 tg Exp $");
#endif #endif
#define MKSH_VERSION "R36 2009/03/15" #define MKSH_VERSION "R36 2009/03/16 ~test"
#ifndef MKSH_INCLUDES_ONLY #ifndef MKSH_INCLUDES_ONLY