next attempt at fixing IFS-subst-2

This commit is contained in:
tg 2014-06-09 10:41:03 +00:00
parent ccf991486f
commit 30bbb90f75
2 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.647 2014/05/29 21:30:45 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.648 2014/06/09 10:41:01 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,
@ -3726,7 +3726,6 @@ expected-stdout:
name: IFS-subst-2 name: IFS-subst-2
description: description:
Check leading whitespace after trim does not make a field Check leading whitespace after trim does not make a field
expected-fail: yes
stdin: stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; } showargs() { for i; do echo -n " <$i>"; done; echo; }
x="X 1 2" x="X 1 2"

17
eval.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.148 2014/05/27 13:00:30 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.149 2014/06/09 10:41:03 tg Exp $");
/* /*
* string expansion * string expansion
@ -702,10 +702,11 @@ expand(
*/ */
x.str = trimsub(str_val(st->var), x.str = trimsub(str_val(st->var),
dp, st->stype); dp, st->stype);
if (quote || x.str[0] != '\0') if (x.str[0] != '\0') {
word = IFS_WS;
type = XSUB; type = XSUB;
else } else
type = XNULLSUB; type = quote ? XSUB : XNULLSUB;
if (f&DOBLANK) if (f&DOBLANK)
doblank++; doblank++;
st = st->prev; st = st->prev;
@ -796,9 +797,11 @@ expand(
if (f&DOBLANK) { if (f&DOBLANK) {
doblank--; doblank--;
/* /*
* not really correct: x=; "$x$@" should * XXX not really correct:
* generate a null argument and * x=; "$x$@"
* set A; "${@:+}" shouldn't. * should generate a null argument and
* set A; "${@:+}"
* shouldn't.
*/ */
if (dp == Xstring(ds, dp)) if (dp == Xstring(ds, dp))
word = IFS_WS; word = IFS_WS;