Bug 141147 - while statement hides values assigned
while statement hides values assigned
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: bash (Show other bugs)
3.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-29 11:54 EST by John P. bland
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-11-29 12:16:21 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John P. bland 2004-11-29 11:54:59 EST
Description of problem: when executing a while statement and assigning
a value to a variable, the value does not exist after the while loop
is completed:

The following is the script

cd /usr/share/terminfo/w
x2=""                                
export x2                            
 ls wy50*|while read x1                
 do                                  
   if [ "X"$x2 = "X" ]               
     then :                          
   else                              
     x2=$x2","                       
   fi                                
   x2=$x2$x1                         
 done                                
echo $x2                             



Version-Release number of selected component (if applicable):

2.05b.0

How reproducible:

See above command segment

Steps to Reproduce:
1.
2.
3.
  
Actual results:

x2=""

Expected results:

wy50,wy50-mc,wy50-vb,wy50-w,wy50-wvb   

Additional info:

for x1 in `ls wy50*`  

instead of 

ls wy50*|while read x1   

does work
Comment 1 John P. bland 2004-11-29 11:57:13 EST
in expected results the variable x2 should be set to the listed data
Comment 2 Tim Waugh 2004-11-29 12:16:21 EST
Please see the bash FAQ, question E4: /usr/share/doc/bash-*/FAQ.

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