Mail Archives: cygwin/2004/05/25/10:46:29
Interesting tests. I still can't get it to fail...
What terminal are you using? Perhaps there's something weird going on with
flow control as descriptors are dup'd for the utilities there?
I'm using plain old winblows console.
Did you try the regular echo instead of the builtin? It may have different
characteristics
with regard to this.
> uname -a
CYGWIN_NT-5.1 kulack 1.5.9(0.112/4/2) 2004-03-18 23:05 i686 unknown
unknown Cygwin
Bash /kulack/test/test
> cygcheck -cd bash
Cygwin Package Information
Package Version
bash 2.05b-16
Bash /kulack/test/test
> echo $CYGWIN
Also, the zz.sh script wouldn't run correctly for me unless I made it used
the magic number #!/bin/bash,
it was running sh instead of bash and didn't support some of the
constructs used.
Some weirdness with sh versus bash mode... I never had to pay much
attention
to the relationships there, but perhaps that's related to the cause?
Bash /kulack/test/test
> echo $SHELL
/bin/bash
"The stuff we call "software" is not like anything that human society
is used to thinking about. Software is something like a machine, and
something like mathematics, and something like language, and
something like thought, and art, and information...
but software is not in fact any of those other things."
Bruce Sterling - The Hacker Crackdown
Fred A. Kulack - IBM eServer iSeries - Enterprise Application Solutions
ERP, Java DB2 access, Jdbc, JTA, etc...
IBM in Rochester, MN (Phone: 507.253.5982 T/L 553-5982)
mailto:kulack/us.ibm.com Personal: mailto:kulack/magnaspeed.net
AIM Home:FKulack AIM Work:FKulackWrk
MSN Work: fakulack/hotmail.com (replace email / with @)
"Hannu E K Nevalainen" <garbage_collector AT telia DOT com>
Sent by: cygwin-owner AT cygwin DOT com
05/24/2004 03:27 PM
To
<cygwin AT cygwin DOT com>
cc
Subject
RE: echo vs. ls race condition?
> From: Henry S. Thompson
> Sent: Monday, May 24, 2004 6:32 PM
> Fred Kulack <kulack AT we DOT bigblue DOT xxx> writes:
>
> >> Short summary: a loop with echo and ls does not produce well-ordered
> >> output
> >
> > For what it's worth, it works fine on my system.
> > XP Professional
> > bash 2.05b-16
> >
> > I always try an update and see if its still happens when I find
> something
> > not quite right.
>
> Thanks for (failing to) reproduce, but I did a complete update before
> reporting, and indeed that _is_ the bash I'm using -- sorry that in my
> first message, I reported what _bash_ itself thinks, as opposed to
> what cygwin thinks.
FWIW; I can reproduce it. It seems to me that it is some kind of problem
with bash's use of subshells in loops (synchronizing output). I have no
knowledge of the internals here, so bear with me.
I've changed your script to be little less (runs shorter time), show
better
what happens... and also adjusted for the fact that I have a bash function
for "ls" that got in the way. (cause: --classify)
$ md zz && cd zz
$ cat ../zz.sh
x=10
while [ $x -lt 20 ]; do echo -en "\r$x ";mkdir $x; x=`expr $x + 1`; done
for d in *; do echo -en "\r$d ";touch $d/aaa-$d; touch $d/bbb-$d; done
command ls -d * | while read d; do echo -e "\n-$d-"; ls $d ; done
NOTE: For me, often the FIRST run after a 'rm -rf *' the script succeeds -
then if you do the following, it fails;
$ command ls -d * | while read d; do echo -e "\n-$d-"; ls $d ; done
-10-
aaa-10 bbb-10
-11-
aaa-11 bbb-11
-12-
aaa-12 bbb-12
-13-
aaa-13 bbb-13
-14-
aaa-14 bbb-14
-15-
aaa-15 bbb-15
-16-
aaa-16 bbb-16
-17-
-18-
aaa-17 bbb-17
aaa-18 bbb-18
-19-
aaa-19 bbb-19
As the following succeeds, I'm lead to believe what I said earlier - not
that it is equivalent though:
$ command ls -d * | while read d; do echo -en "\n-$d-\n$(ls $d)" ; done
-10-
aaa-10
bbb-10
-11-
aaa-11
bbb-11
-12-
aaa-12
bbb-12
-13-
aaa-13
bbb-13
-14-
aaa-14
bbb-14
-15-
aaa-15
bbb-15
-16-
aaa-16
bbb-16
-17-
aaa-17
bbb-17
-18-
aaa-18
bbb-18
-19-
aaa-19
bbb-19
All this seems somehow be triggered by the fact that diskcaching plays a
role here: i.e. the first run has this "time" output;
real 0m5.385s
user 0m2.040s
sys 0m3.670s
the second run and forth;
real 0m1.233s
user 0m0.420s
sys 0m0.850s
(w some tiny differences).
I have tried to use { _list_of_commands_ } as described in the bash
manual;
i.e, this runs, but has the same problem:
$ command ls -d * | while read d; do { echo -e "\n-$d-"; ls $d ; } ; done
The idea is to force 'do _list_ ;done' to be executed in the "local"
shell,
not a subshell. I've tried other variants of it, but have failed to make
it
work;
Here I wonder: Is that yet another of those irritating
documentation-failure(-to-understand) issues that I stumble on quite
often?
$ uname -a
CYGWIN_NT-5.0 P450 1.5.10s(0.115/4/2) 20040519 13:51:37 i686 unknown
unknown
Cygwin
$ cygcheck -cd bash
Cygwin Package Information
Package Version
bash 2.05b-16
$ echo $CYGWIN
notitle glob check_case:strict server=1
Tests run on a FAT32 partition on a P2/450Mhz, W2K adv server, SP4++ - if
that has any influence.
/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E
** on a mailing list; please keep replies on that particular list **
-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--
--
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/
--
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/
- Raw text -