Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 20564 - read builtin corrupts parameter assignment in loop
read builtin corrupts parameter assignment in loop
Status: CLOSED DUPLICATE of bug 19747
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
Depends On:
  Show dependency treegraph
Reported: 2000-11-09 04:05 EST by b.g.m.kusters
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-11-10 04:42:20 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description b.g.m.kusters 2000-11-09 04:05:52 EST
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.

echo "1" > x2
echo "2" >> x2
echo "Error parameter not exported"
cat x2|while read p1
 echo "d1 = $d"
 echo "d2 = $d"
echo "d3 = $d"

echo ""
echo "No Error parameter is exported"
set $(cat x2)
while [ $# -ne 0 ]
 shift 1
 echo "d1 = $d"
 echo "d2 = $d"
echo "d3 = $d"
Comment 1 b.g.m.kusters 2000-11-09 04:10:42 EST
TESTED with RedHat 6.2 not 4.2
Comment 2 Bernhard Rosenkraenzer 2000-11-10 04:46:27 EST
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 ***

Note You need to log in before you can comment on or make changes to this bug.