bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird bug in small for loop and here documents and bash-4.x


From: Chet Ramey
Subject: Re: weird bug in small for loop and here documents and bash-4.x
Date: Sun, 21 Mar 2010 21:21:36 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 3/21/10 1:55 AM, Mike Frysinger wrote:
> i have a small bit of code in a function:
> foo() {
>       local f
>       for f in src/assembler.S src/assembler_opt.S ; do
>               cat <<-EOF >> ${f}
>               #ifdef __ELF__
>               .section .note.GNU-stack,"",%progbits
>               #endif
>               EOF
>       done
> }
> 
> under bash-4.0_p37 and bash-4.1_p2, the first file is correctly appended but 
> the second is not.  using bash-3.2_p50 and i get correct behavior -- both 
> files are appended.  we're seeing this on a bunch of different Gentoo systems.
> 
> i'm having a hard time debugging this because as soon as i stick any 
> statement 
> inside the for loop (before or after), both files are updated with bash-4.x.  
> for example, simply adding a `:` or an `echo` before the cat.
> 
> when i strace bash, i see both files being opened, set to stdout, and then 
> cat 
> executed, but only in the first file (src/assembler.S) does there appear to 
> be 
> any data waiting for cat on stdin.  the second file's cat reads stdin and 
> gets 
> back 0 bytes.
> 
> trying to debug the bash source itself is a bit beyond me though ...

You might have to.  I can't reproduce this on Mac OS X, Ubuntu, or RHEL.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]