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 [email protected] http://cnswww.cns.cwru.edu/~chet/