fix initial IFSWS not ignored when expanding, noticed by Seb <sbb@tuxfamily.org>

This commit is contained in:
tg 2013-11-17 22:28:51 +00:00
parent 2008bab5a0
commit 973c7a55c2
3 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.634 2013/10/09 11:59:26 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.635 2013/11/17 22:28:49 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 $
@ -31,7 +31,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 R48 2013/10/08 @(#)MIRBSD KSH R48 2013/11/17
description: description:
Check version of shell. Check version of shell.
stdin: stdin:
@ -40,7 +40,7 @@ name: KSH_VERSION
category: shell:legacy-no category: shell:legacy-no
--- ---
expected-stdout: expected-stdout:
@(#)LEGACY KSH R48 2013/10/08 @(#)LEGACY KSH R48 2013/11/17
description: description:
Check version of legacy shell. Check version of legacy shell.
stdin: stdin:
@ -3674,6 +3674,8 @@ stdin:
x=" A : B::D" x=" A : B::D"
echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 13 $x showargs 13 $x
x="X 1 2"
showargs 14 shift ${x#X}
expected-stdout: expected-stdout:
1: [] [b] [] 1: [] [b] []
2: [:b::] 2: [:b::]
@ -3688,6 +3690,7 @@ expected-stdout:
<11> <h:ith:ere> <11> <h:ith:ere>
12: [A] [B] [] [D] 12: [A] [B] [] [D]
<13> <A> <B> <> <D> <13> <A> <B> <> <D>
<14> <shift> <1> <2>
--- ---
name: integer-base-err-1 name: integer-base-err-1
description: description:

5
eval.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.143 2013/09/24 20:19:44 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.144 2013/11/17 22:28:51 tg Exp $");
/* /*
* string expansion * string expansion
@ -719,7 +719,8 @@ expand(
*/ */
x.str = trimsub(str_val(st->var), x.str = trimsub(str_val(st->var),
dp, st->stype); dp, st->stype);
if (x.str[0] != '\0' || st->quotep) word = quote ? IFS_WORD : IFS_WS;
if (quote || x.str[0] != '\0')
type = XSUB; type = XSUB;
else else
type = XNULLSUB; type = XNULLSUB;

4
sh.h
View File

@ -164,9 +164,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.675 2013/11/17 22:23:29 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.676 2013/11/17 22:28:51 tg Exp $");
#endif #endif
#define MKSH_VERSION "R48 2013/10/08" #define MKSH_VERSION "R48 2013/11/17"
/* arithmetic types: C implementation */ /* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES #if !HAVE_CAN_INTTYPES