From 6e515f1d45fe64e8775ba656c288478e732d129e Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Thu, 23 Jul 2020 16:03:57 -0700 Subject: [PATCH] Fix command substitutions run on the same line as a here-doc (#91) When a command substitution is run on the same line as a here-document, a syntax error occurs due to a regression introduced in ksh93u+ 2011-04-15: true << EOF; true $(true) EOF syntax error at line 1: `< * * * ***********************************************************************/ -#define SH_RELEASE "93u+m 2020-07-22" +#define SH_RELEASE "93u+m 2020-07-23" diff --git a/src/cmd/ksh93/sh/lex.c b/src/cmd/ksh93/sh/lex.c index 916561b57f98..3ea25437e38e 100644 --- a/src/cmd/ksh93/sh/lex.c +++ b/src/cmd/ksh93/sh/lex.c @@ -1563,6 +1563,7 @@ static int comsub(register Lex_t *lp, int endtok) { register int n,c,count=1; register int line=lp->sh->inlineno; + struct ionod *inheredoc = lp->heredoc; char *first,*cp=fcseek(0),word[5]; int off, messages=0, assignok=lp->assignok, csub; struct lexstate save; @@ -1689,7 +1690,7 @@ static int comsub(register Lex_t *lp, int endtok) lp->lexd.dolparen--; lp->lex = save; lp->assignok = (endchar(lp)==RBRACT?assignok:0); - if(lp->heredoc) + if(lp->heredoc && !inheredoc) errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax5,lp->sh->inlineno,lp->heredoc->ioname); return(messages); } diff --git a/src/cmd/ksh93/tests/heredoc.sh b/src/cmd/ksh93/tests/heredoc.sh index 1cabd44e38e0..d75443345a18 100755 --- a/src/cmd/ksh93/tests/heredoc.sh +++ b/src/cmd/ksh93/tests/heredoc.sh @@ -498,4 +498,16 @@ print foo > $tmp/foofile x=$( $SHELL 2> /dev/null 'read <<< $(<'"$tmp"'/foofile) 2> /dev/null;print -r "$REPLY"') [[ $x == foo ]] || err_exit '<<< $( /dev/null && err_exit "a here-doc that isn't completed before the closing ) in a command substitution doesn't cause an error" + +# ====== exit $((Errors<125?Errors:125))