This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

echo vs. ls race condition?


Apologies if this is a known bug, or actually a bash problem, but I
can only reproduce it under cygwin (not linux or solaris, same bash
version (2.05b0) on linux, different (2.02.0) on solaris).

Hard to know what to search for, but nothing obvious in archives.

Short summary:  a loop with echo and ls does not produce well-ordered
output

Recipe to reproduce:

 > mkdir test
 > cd test
 > x=1
 > while [ $x -lt 200 ]; do mkdir $x; x=`expr $x + 1`; done
 > for d in *; do touch $d/aaa; touch $d/bbb; done
 > ls -d * | while read d; do echo $d; ls $d ; done > raceLog

Looking at raceLog will show e.g.

105
aaa
bbb
106
107
108
aaa
bbb
aaa
bbb
aaa
bbb

which is not what it should be. . .

Running up-to-date installations on XP and ME (cygcheck for the latter
[removed -- mail not getting through?]).

ht
-- 
 Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                     Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
            Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                   URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]