Bug 20564 - read builtin corrupts parameter assignment in loop
Summary: read builtin corrupts parameter assignment in loop
Status: CLOSED DUPLICATE of bug 19747
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
(Show other bugs)
Version: 6.2
Hardware: i386 Linux
medium
medium
Target Milestone: ---
Assignee: Bernhard Rosenkraenzer
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-11-09 09:05 UTC by b.g.m.kusters
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

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


Attachments (Terms of Use)

Description b.g.m.kusters 2000-11-09 09:05:52 UTC
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"

Comment 1 b.g.m.kusters 2000-11-09 09:10:42 UTC
TESTED with RedHat 6.2 not 4.2

Comment 2 Bernhard Rosenkraenzer 2000-11-10 09:46:27 UTC
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.