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.

> Is the below expected behavior? or bug? Values assigned to variables
> within the loop, are not visible outside the loop. Using something
> like 'while true' works as I would expect.
>
>
> #!/bin/bash
> ## script: testing
> ## test variable visibility
>
> 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
>
>
> [hal@feenix hal]$ bash -version
> GNU bash, version 2.04.11(1)-release (i386-redhat-linux-gnu)
> Copyright 1999 Free Software Foundation, Inc.
>
>
>
>
>

-- 
-Statux



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

Reply via email to