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.




-- 
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