[Top][All Lists]

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

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

From: Mike Frysinger
Subject: weird bug in small for loop and here documents and bash-4.x
Date: Sun, 21 Mar 2010 01:55:54 -0400
User-agent: KMail/1.13.1 (Linux/2.6.33; KDE/4.4.1; x86_64; ; )

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

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 ...

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

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