Tested in bash and bash2 Parameter assignment in loop is not exported out of the loop if read is used see script. Same error occures if read is used in combinatie with pipe eg. tail -n 1 x2 | read p1 p2. No assignment to parameters read take place. #!/bin/bash2 echo "1" > x2 echo "2" >> x2 echo "Error parameter not exported" d="" cat x2|while read p1 do echo "d1 = $d" d="${d}${p1}" echo "d2 = $d" done echo "d3 = $d" echo "" echo "No Error parameter is exported" d="" set $(cat x2) while [ $# -ne 0 ] do p1=$1 shift 1 echo "d1 = $d" d="${d}${p1}" echo "d2 = $d" done echo "d3 = $d"
TESTED with RedHat 6.2 not 4.2
This is another effect of the modifications to make bash compliant to the Single UNIX Specification (See bug #19747). *** This bug has been marked as a duplicate of 19747 ***