On Thu, Jan 18, 2001 at 10:34:30PM -0500, Statux wrote:
> This is correct behavior (from what I've known). The variables in the loop
> are defined as temporary variables.. they have scope limited to the loop.

Not all loops:

num=0

#cat tmp | while read line ; do
while [ $num -eq 0 ]; do
 
 num=1
 echo $num

done

echo $num

#--- eof %

[hal@feenix hal]$ testing
1
1

It has something to do with that 'cat'. I just can't think of a
logical reason why.

> > num=0
> > echo 1 > tmp
> >
> > cat tmp |while read line ; do
> >
> >  num=1
> >  echo $num
> >
> > done
> >
> > echo $num
> >
> >
> > #--- eof testing
> >
> > [hal@feenix hal]$ testing
> > 1
> > 0

bash 1.14 is the same.

-- 
Hal B
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
--



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to