Mail Archives: cygwin/2004/05/24/16:27:59
> 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/
- Raw text -