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: Mon, 22 Mar 2010 21:47:53 -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/22/10 6:21 PM, Mike Frysinger wrote:
> ok, the trouble is that we take the code, save it via `set`, and then restore 
> it.

OK, that was the missing piece.  Not really anything to do with the
redirection code per se.

> the assumption is that what bash outputs is equivalent to the original 
> code.  bash-4 though does not provide equivalent code.

Yeah, that's pretty weird.  An artifact of the changes to print here
documents correctly in the presence of operators like |, ||, and &&.

> so here is the reduced test case:
> $ cat test.sh
> foo() {
>       rm -f a b c
>       for f in a b c; do
>               cat <<-EOF >> ${f}
>               file
>               EOF
>       done
>       grep . a b c
> }
> 
> $ . ./test.sh
> $ foo
> a:file
> b:file
> c:file

The attached patch fixes it for me.  Let me know.

Chet

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

Attachment: deferred-heredocs
Description: Text document


reply via email to

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