On Tue, Jul 13, 2010 at 01:51:31PM -0400, Alex Khesin wrote:
> Configuration Information:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include
> -I../bash/lib   -g -O2 -Wall
> uname output: Linux alexk 2.6.32-gg173-generic #gg173 SMP Wed Jun 23
> 05:24:15 UTC 2010 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
> Bash Version: 4.1
> Patch Level: 5
> Release Status: release
> 
> Description:
> 
> The following script used to work in bash 3.2 but does not work with
> bash 4.x (I tried 4.0, 4.1.5, and 4.1.7)
> 
> ------
> #!/bin/bash
> 
> a=$(/bin/cat << EOF | wc -l
> a
> b
> EOF
> )
> -----
> 
> /tmp/bug.sh: line 3: unexpected EOF while looking for matching `)'
> /tmp/bug.sh: line 8: syntax error: unexpected end of file
> 
> The following works correctly (changed /bin/cat to cat):
> 
> ------
> #!/bin/bash
> 
> a=$(cat << EOF | wc -l
> a
> b
> EOF
> )
> -----
> 
> and so does this (removed | wc -l):
> 
> ------
> #!/bin/bash
> 
> a=$(/bin/cat << EOF
> a
> b
> EOF
> )
> -----

Hmmm ... I would expect that

a=$((/bin/cat|wc -l) <<EOF
a
b
EOF
)

is more correct.

    Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

Reply via email to