When programming with Busybox ash, str in following program will be changed in every while loop as expected, but after while loop the str becomes empty again. /tmp/term_mon_ttys is a test file.
#!/bin/ash
cnt=0
str=
cat /tmp/term_mon_ttys | while read line; do
str="$str $cnt"
cnt=`expr $cnt + 1`
done
echo $str
However, if changing above code to
#!/bin/ash
cnt=0
str=
while [ $cnt -lt 5 ]; do
str="$str $cnt"
cnt=`expr $cnt + 1`
done
echo $str
then after the while loop, the str becomes 0 1 2 3 4.
Anybody noticed this issue?