diff --git a/check.t b/check.t index 03b19e8..53514e7 100644 --- a/check.t +++ b/check.t @@ -1,9 +1,9 @@ -# $MirOS: src/bin/mksh/check.t,v 1.705 2015/08/13 22:06:19 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.706 2015/09/05 20:20:42 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014, 2015 -# Thorsten Glaser +# mirabilos # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission @@ -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 R51 2015/08/13 + @(#)MIRBSD KSH R51 2015/09/05 description: Check version of shell. stdin: @@ -39,7 +39,7 @@ name: KSH_VERSION category: shell:legacy-no --- expected-stdout: - @(#)LEGACY KSH R51 2015/08/13 + @(#)LEGACY KSH R51 2015/09/05 description: Check version of legacy shell. stdin: @@ -2423,7 +2423,7 @@ stdin: print -r -- "| ${v//$'\n'/^} |" expected-stdout: function foo { - vc=<<-EOF + vc=<<-EOF =c $x \x40= EOF @@ -2476,11 +2476,11 @@ stdin: print -r -- "| ${v//$'\n'/^} |" expected-stdout: function foo { - vc=<<- + vc=<<- =c $x \x40= << - vd=<<-"" + vd=<<-"" =d $x \x40= @@ -2538,6 +2538,46 @@ expected-stdout: 3 baz a b baz 3 bla "a b" bla --- +name: heredoc-14 +description: + Check that using multiple here documents works +stdin: + foo() { + echo "got $(cat) on stdin" + echo "got $(cat <&4) on fd#4" + echo "got $(cat <&5) on fd#5" + } + bar() { + foo 4<<-a <<-b 5<<-c + four + a + zero + b + five + c + } + x=$(typeset -f bar) + eval "$x" + y=$(typeset -f bar) + [[ $x = "$y" ]]; echo $? + typeset -f bar + bar +expected-stdout: + 0 + bar() { + foo 4<<-a <<-b 5<<-c + four + a + zero + b + five + c + + } + got zero on stdin + got four on fd#4 + got five on fd#5 +--- name: heredoc-comsub-1 description: Tests for here documents in COMSUB, taken from Austin ML @@ -10566,7 +10606,7 @@ expected-stdout: EOFN } inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() { - cat >|bar <<"EOFN" + cat >|bar <<"EOFN" foo EOFN @@ -10577,7 +10617,7 @@ expected-stdout: EOFN ); } function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { - x=$(cat >|bar <<"EOFN" + x=$(cat >|bar <<"EOFN" foo EOFN ) @@ -10588,7 +10628,7 @@ expected-stdout: EOFN )|tr u x); } function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { - x=$(( cat >|bar <<"EOFN" + x=$(( cat >|bar <<"EOFN" foo EOFN ) | tr u x ) @@ -10599,7 +10639,7 @@ expected-stdout: EOFI } inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() { - cat >bar <<-EOFI + cat >bar <<-EOFI foo EOFI @@ -10610,7 +10650,7 @@ expected-stdout: EOFI ); } function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { - x=$(cat >bar <<-EOFI + x=$(cat >bar <<-EOFI foo EOFI ) @@ -10621,7 +10661,7 @@ expected-stdout: EOFI )|tr u x); } function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { - x=$(( cat >bar <<-EOFI + x=$(( cat >bar <<-EOFI foo EOFI ) | tr u x ) @@ -10712,7 +10752,7 @@ expected-stdout: EOFN); echo $x } inline_heredoc_closed() { - x=$(cat <&1 <<-EOF + [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 1,/^\$/d 0a $x @@ -10824,7 +10864,7 @@ expected-stdout: fi ); } function comsub_patch_motd { - x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF + x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 1,/^\$/d 0a $x @@ -10851,7 +10891,7 @@ expected-stdout: fi )|tr u x); } function reread_patch_motd { - x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF + x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 1,/^\$/d 0a $x diff --git a/lex.c b/lex.c index cd7b0b4..9797014 100644 --- a/lex.c +++ b/lex.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.206 2015/09/05 19:19:06 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.207 2015/09/05 20:20:46 tg Exp $"); /* * states while lexing word @@ -946,6 +946,14 @@ yylex(int cf) c2 = getsc(); } else if (c2 == '<') iop->ioflag |= IOHERESTR; + if (c2 == ' ') { + /*XXX reentrancy hack IONDELIM */ + c2 = getsc(); + if (c2 != '\n') { + ungetsc(c2); + c2 = ' '; + } + } ungetsc(c2); if (c2 == '\n') iop->ioflag |= IONDELIM; diff --git a/sh.h b/sh.h index 303756e..4ab16ab 100644 --- a/sh.h +++ b/sh.h @@ -172,9 +172,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.742 2015/09/05 19:19:10 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.743 2015/09/05 20:20:46 tg Exp $"); #endif -#define MKSH_VERSION "R51 2015/08/13" +#define MKSH_VERSION "R51 2015/09/05" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES diff --git a/tree.c b/tree.c index 59dc7c6..37f0f13 100644 --- a/tree.c +++ b/tree.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.75 2015/09/05 19:19:11 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.76 2015/09/05 20:20:48 tg Exp $"); #define INDENT 8 @@ -285,15 +285,14 @@ pioact(struct shf *shf, struct ioword *iop) if (type == IOHERE) { if (iop->delim) wdvarput(shf, iop->delim, 0, WDS_TPUTS); - if (flag & IOHERESTR) - shf_putc(' ', shf); + /*XXX see IONDELIM hack */ } else if (iop->name) { if (flag & IONAMEXP) print_value_quoted(shf, iop->name); else wdvarput(shf, iop->name, 0, WDS_TPUTS); - shf_putc(' ', shf); } + shf_putc(' ', shf); prevent_semicolon = false; }