[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash-4.0 regression with here documents and multiline subshells
From: |
Chet Ramey |
Subject: |
Re: bash-4.0 regression with here documents and multiline subshells |
Date: |
Thu, 26 Feb 2009 17:29:18 -0500 |
User-agent: |
Thunderbird 2.0.0.19 (Macintosh/20081209) |
Mike Frysinger wrote:
> the documentation shows that for <<< here documents, the word must be right
> after the operator (although it doesnt really spell it out). not sure if
> that
> should be made explicit and to have bash reject it, or to fix up this issue
> so
> it works again ...
>
> at any rate, this style usage, while seemingly not allowed by the docs, works
> fine with older/current bash:
> echo $(cat <<< "foo")
>
> however, when we go multiline, bash-4.0 gets into a parsing loop:
> $ cat test.sh
> #!/bin/bash
> echo $(
> cat <<< "foo"
> )
> $ ./test.sh
> ./test.sh: line 2: unexpected EOF while looking for matching `)'
> ./test.sh: line 5: syntax error: unexpected end of file
>
> if we go ahead and remove that whitespace after the <<<, then it works fine:
> $ cat test.sh
> #!/bin/bash
> echo $(
> cat <<<"foo"
> )
> $ ./test.sh
> foo
Problem with the $(...) parser not knowing the difference between << and
<<<. The attached patch fixes it.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.0/parse.y 2009-01-08 08:29:12.000000000 -0500
--- parse.y 2009-02-26 17:22:15.000000000 -0500
***************
*** 3395,3400 ****
else
shell_ungetc (peekc);
! tflags |= LEX_HEREDELIM;
! lex_firstind = -1;
continue;
}
--- 3402,3410 ----
else
shell_ungetc (peekc);
! if (peekc != '<')
! {
! tflags |= LEX_HEREDELIM;
! lex_firstind = -1;
! }
continue;
}