Description of problem: Fedora 11's bash (bash4) doesn't accept this script: # cat bla.sh #!/bin/bash e=$(cat << EOF contents EOF) echo "$e" # /bin/bash ./bla.sh ./bla.sh: line 2: unexpected EOF while looking for matching `)' ./bla.sh: line 7: syntax error: unexpected end of file ksh and zsh do, dash also rejects it: # /bin/dash ./bla.sh ./bla.sh: 6: Syntax error: end of file unexpected (expecting ")") On Fedora 10, all of sh, bash, ksh, zsh process this script, dash issues an error as above. Question: Is this simply a behavioral change having been introduced to bash4 or is this a functional regression? So far, I haven't further investigated and am not sure about it. Version-Release number of selected component (if applicable): bash-4.0-0.4.rc1.fc11.x86_64 Additional info: Moving the ')' to the line following the 'EOF' makes this script functional again. i.e. using this: #!/bin/bash e=$(cat << EOF contents EOF ) echo "$e"
This is expected behavior according to posix. Therefore this is bug in older bash. Quotation from posix: The here-document shall be treated as a single word that begins after the next <newline> and continues until there is a line containing only the delimiter and a <newline>, with no <blank>s in between. Then the next here-document starts, if there is one. The format is as follows: [n]<<word here-document delimiter Therefore in your first example is missing <newline> before `)' In my eyes this is bug in previous version of bash and in ksh, zsh and any other? I will add maintainers of these shells (tcsh, ksh and zsh) to CC.
Ralf, have you tried F-10 versions of other shells? Can you try rawhide versions?
(In reply to comment #2) > Ralf, > have you tried F-10 versions of other shells? Which shells else do you have in mind? As mentioned in my initial report, I tried sh, ksh, zsh, dash and bash on both F11 (yesterday's rawhide, in chroots on F10/x86_64) and F10. (In reply to comment #1) > This is expected behavior according to posix. OK, however ..., please note this is a /bin/bash script, not a supposed-to-be POSIX conforming /bin/sh script. i.e. the POSIX-dialect of shell languages is largely irrelevant here. This is the "bash-dialect" -- Of course, bash has the liberty to change the "bash dialect", but then this change would be a backward incompatibile change ;)
Nevertheless this will not be changed in rawhide.
If you prefer to throw away ksh-incompatibility and to further add to the already long zoo of general shell incompatiblities ;) Please, send a patch to upstream autoconf such this incompatibility can be documented in Autoconf.info's.