Description:
It appears to me that the while loop code is failing to "export" the changed value of
an integer variable although I did not try it on any other type of variable. The loop
picks up the proper value from its preceding code, but code after the loop does not
see the changed changed values. This is contrary to the operation of the "for" loop.
Repeat-By:
The following script demonstrates the problem, starting at 7, add three for the "a b c" and one
for the "x", the final value should be 11. The while loop starts with the proper value for
"addcount" but does not "export" the changed value outside of the loop. See the output
-------------------------
let addcount=7
for x in a b c
do
let addcount=$addcount+1
echo "loop: addcount=$addcount"
done
echo "x" | while read x
do
let addcount=$addcount+1
echo "while loop: addcount=$addcount"
done