Re: bash 4 parse error on here-document in $()
Machine Type: i386-redhat-linux-gnu Bash Version: 4.0 Patch Level: 23 Release Status: release Description: Bash 4.0 errors on a here-document enclosed in $(). For example: x=$(cat EOF foo bar EOF) Ctrl+D -bash: unexpected EOF while looking for matching `)' -bash: syntax error: unexpected end of file The shell is allowed to do this. A here-document is supposed to be terminated by a line containing the delimiter followed by a newline, not EOF. However, the behavior is useful enough that I changed the parser to support it in bash-4.1. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: bash 4 parse error on here-document in $()
Thank you for setting me straight! I had checked the POSIX spec before sending the report but missed the part about the delimiter having to be immediately followed by newline. Martin On 09/24/2009 06:39 AM, Chet Ramey wrote: Machine Type: i386-redhat-linux-gnu Bash Version: 4.0 Patch Level: 23 Release Status: release Description: Bash 4.0 errors on a here-document enclosed in $(). For example: x=$(catEOF foo bar EOF) Ctrl+D -bash: unexpected EOF while looking for matching `)' -bash: syntax error: unexpected end of file The shell is allowed to do this. A here-document is supposed to be terminated by a line containing the delimiter followed by a newline, not EOF. However, the behavior is useful enough that I changed the parser to support it in bash-4.1. Chet
bash 4 parse error on here-document in $()
Configuration Information [Automatically generated, do not change]: Machine: i386 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables uname output: Linux mslaptop 2.6.30.5-43.fc11.i586 #1 SMP Thu Aug 27 21:18:54 EDT 2009 i686 i686 i386 GNU/Linux Machine Type: i386-redhat-linux-gnu Bash Version: 4.0 Patch Level: 23 Release Status: release Description: Bash 4.0 errors on a here-document enclosed in $(). For example: x=$(cat EOF foo bar EOF) Ctrl+D -bash: unexpected EOF while looking for matching `)' -bash: syntax error: unexpected end of file Repeat-By: Save the following script in a file named t.sh, execute the file and observe the parse error: ./t.sh: line 7: unexpected EOF while looking for matching `)' ./t.sh: line 13: syntax error: unexpected end of file #!/bin/bash x=`cat EOF foo bar EOF` y=$(cat EOF foo bar EOF) [ $x != $y ] exit 1