LANGUAGE CHANGE: $((…)) results are now IFS-split, as per POSIX 201x

This commit is contained in:
tg
2014-06-09 11:16:07 +00:00
parent 2f620132af
commit b7c41f240c
2 changed files with 15 additions and 17 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.649 2014/06/09 11:13:17 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.650 2014/06/09 11:16:06 tg Exp $
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44 # OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
#- #-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -3736,7 +3736,6 @@ expected-stdout:
name: IFS-arith-1 name: IFS-arith-1
description: description:
http://austingroupbugs.net/view.php?id=832 http://austingroupbugs.net/view.php?id=832
expected-fail: yes
stdin: stdin:
${ZSH_VERSION+false} || emulate sh ${ZSH_VERSION+false} || emulate sh
${BASH_VERSION+set -o posix} ${BASH_VERSION+set -o posix}

29
eval.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.149 2014/06/09 10:41:03 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.150 2014/06/09 11:16:07 tg Exp $");
/* /*
* string expansion * string expansion
@ -324,9 +324,9 @@ expand(
} }
continue; continue;
case EXPRSUB: case EXPRSUB:
word = IFS_WORD;
tilde_ok = 0; tilde_ok = 0;
if (f & DONTRUNCOMMAND) { if (f & DONTRUNCOMMAND) {
word = IFS_WORD;
*dp++ = '$'; *dp++ = '('; *dp++ = '('; *dp++ = '$'; *dp++ = '('; *dp++ = '(';
while (*sp != '\0') { while (*sp != '\0') {
Xcheck(ds, dp); Xcheck(ds, dp);
@ -343,11 +343,10 @@ expand(
v_evaluate(&v, substitute(sp, 0), v_evaluate(&v, substitute(sp, 0),
KSH_UNWIND_ERROR, true); KSH_UNWIND_ERROR, true);
sp = strnul(sp) + 1; sp = strnul(sp) + 1;
cp = str_val(&v); x.str = str_val(&v);
while (*cp) { type = XSUB;
Xcheck(ds, dp); if (f & DOBLANK)
*dp++ = *cp++; doblank++;
}
} }
continue; continue;
case OSUBST: { case OSUBST: {
@ -683,7 +682,7 @@ expand(
*dp = '\0'; *dp = '\0';
quote = st->quotep; quote = st->quotep;
f = st->f; f = st->f;
if (f&DOBLANK) if (f & DOBLANK)
doblank--; doblank--;
switch (st->stype & 0x17F) { switch (st->stype & 0x17F) {
case '#': case '#':
@ -707,7 +706,7 @@ expand(
type = XSUB; type = XSUB;
} else } else
type = quote ? XSUB : XNULLSUB; type = quote ? XSUB : XNULLSUB;
if (f&DOBLANK) if (f & DOBLANK)
doblank++; doblank++;
st = st->prev; st = st->prev;
continue; continue;
@ -739,7 +738,7 @@ expand(
dp, len), KSH_UNWIND_ERROR); dp, len), KSH_UNWIND_ERROR);
x.str = str_val(st->var); x.str = str_val(st->var);
type = XSUB; type = XSUB;
if (f&DOBLANK) if (f & DOBLANK)
doblank++; doblank++;
st = st->prev; st = st->prev;
continue; continue;
@ -757,7 +756,7 @@ expand(
case 0x100 | 'Q': case 0x100 | 'Q':
dp = Xrestpos(ds, dp, st->base); dp = Xrestpos(ds, dp, st->base);
type = XSUB; type = XSUB;
if (f&DOBLANK) if (f & DOBLANK)
doblank++; doblank++;
st = st->prev; st = st->prev;
continue; continue;
@ -794,7 +793,7 @@ expand(
* other stuff inside the quotes). * other stuff inside the quotes).
*/ */
type = XBASE; type = XBASE;
if (f&DOBLANK) { if (f & DOBLANK) {
doblank--; doblank--;
/* /*
* XXX not really correct: * XXX not really correct:
@ -812,7 +811,7 @@ expand(
case XSUBMID: case XSUBMID:
if ((c = *x.str++) == 0) { if ((c = *x.str++) == 0) {
type = XBASE; type = XBASE;
if (f&DOBLANK) if (f & DOBLANK)
doblank--; doblank--;
continue; continue;
} }
@ -833,7 +832,7 @@ expand(
word = IFS_WORD; word = IFS_WORD;
if ((x.str = *x.u.strv++) == NULL) { if ((x.str = *x.u.strv++) == NULL) {
type = XBASE; type = XBASE;
if (f&DOBLANK) if (f & DOBLANK)
doblank--; doblank--;
continue; continue;
} }
@ -882,7 +881,7 @@ expand(
if (x.split) if (x.split)
subst_exstat = waitlast(); subst_exstat = waitlast();
type = XBASE; type = XBASE;
if (f&DOBLANK) if (f & DOBLANK)
doblank--; doblank--;
continue; continue;
} }