diff --git a/check.t b/check.t index e00c9d3..2cbdcc9 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.679 2015/02/13 12:51:30 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.680 2015/02/19 22:26:47 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -30,7 +30,7 @@ # (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date expected-stdout: - @(#)MIRBSD KSH R50 2015/02/13 + @(#)MIRBSD KSH R50 2015/02/19 description: Check version of shell. stdin: @@ -39,7 +39,7 @@ name: KSH_VERSION category: shell:legacy-no --- expected-stdout: - @(#)LEGACY KSH R50 2015/02/13 + @(#)LEGACY KSH R50 2015/02/19 description: Check version of legacy shell. stdin: @@ -2480,6 +2480,51 @@ expected-stdout: } | | vapp1^vapp2^ | --- +name: heredoc-12 +description: + Check here documents can use $* and $@; note shells vary: + • pdksh 5.2.14 acts the same + • dash has 1 and 2 the same but 3 lacks the space + • ksh93, bash4 differ in 2 by using space ipv colon +stdin: + set -- a b + nl=' + ' + IFS=" $nl"; n=1 + cat < "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b +expected-stdout: + 1 0 + 2 0 + 3 0 + 4 1 + 5 1 + 6 1 + 7 ok + 8 ok + <9> . +--- name: IFS-arith-1 description: http://austingroupbugs.net/view.php?id=832 @@ -8342,13 +8410,21 @@ name: varexpand-null-1 description: Ensure empty strings expand emptily stdin: - print x ${a} ${b} y - print z ${a#?} ${b%?} w - print v ${a=} ${b/c/d} u + print s ${a} . ${b} S + print t ${a#?} . ${b%?} T + print r ${a=} . ${b/c/d} R + print q + print s "${a}" . "${b}" S + print t "${a#?}" . "${b%?}" T + print r "${a=}" . "${b/c/d}" R expected-stdout: - x y - z w - v u + s . S + t . T + r . R + q + s . S + t . T + r . R --- name: varexpand-null-2 description: @@ -8368,7 +8444,6 @@ stdin: showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } x=; showargs 1 "$x"$@ set A; showargs 2 "${@:+}" -expected-fail: yes expected-stdout: <1> <> . <2> <> . diff --git a/eval.c b/eval.c index 46f0d0f..02beae8 100644 --- a/eval.c +++ b/eval.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.164 2015/02/19 22:01:13 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.165 2015/02/19 22:26:48 tg Exp $"); /* * string expansion @@ -847,15 +847,20 @@ expand( continue; } c = ifs0; + if ((f & DOHEREDOC)) { + /* pseudo-field-split reliably */ + if (c == 0) + c = ' '; + break; + } if ((f & DOSCALAR)) { /* do not field-split */ if (x.split) { c = ' '; break; } - if (c == 0) { + if (c == 0) continue; - } } if (c == 0) { if (quote && !x.split) diff --git a/exec.c b/exec.c index a8dab5c..ba812ee 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.145 2015/02/19 22:00:03 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.146 2015/02/19 22:26:49 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL "/bin/sh" @@ -1492,7 +1492,7 @@ hereinval(const char *content, int sub, char **resbuf, struct shf *shf) if (yylex(sub) != LWORD) internal_errorf("%s: %s", "herein", "yylex"); source = osource; - ccp = evalstr(yylval.cp, DOSCALAR); + ccp = evalstr(yylval.cp, DOSCALAR | DOHEREDOC); } if (resbuf == NULL) diff --git a/sh.h b/sh.h index f4f8b35..5c38a69 100644 --- a/sh.h +++ b/sh.h @@ -169,9 +169,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.711 2015/02/13 12:51:33 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.712 2015/02/19 22:26:50 tg Exp $"); #endif -#define MKSH_VERSION "R50 2015/02/13" +#define MKSH_VERSION "R50 2015/02/19" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES @@ -1402,6 +1402,7 @@ struct ioword { #define DOMARKDIRS BIT(10) /* force markdirs behaviour */ #define DOTCOMEXEC BIT(11) /* not an eval flag, used by sh -c hack */ #define DOSCALAR BIT(12) /* change field handling to non-list context */ +#define DOHEREDOC BIT(13) /* change scalar handling to heredoc body */ #define X_EXTRA 20 /* this many extra bytes in X string */