Strange shellscript behaviour?
From: Bjørn Augestad (boa_at_metasystems.no)
Date: Wed, 01 Dec 2004 19:32:46 GMT
Below is a tiny example of a problem I ran into today. The script
contains two loops. Both loops reads lines from a file and modifies FOO.
For some strange reason FOO is reset to 1 after the first loop, but
keeps the value assigned(4) after the second loop.
Is this a bug or am I missing something obvious?
PS: This is GNU bash, version 2.05b.0(1)-release
cat ~/.bashrc | while read line; do
echo $FOO # Here foo is 1
while read line; do
done < ~/.bashrc
echo $FOO # But here it is 4