Bug 141147 - while statement hides values assigned
Summary: while statement hides values assigned
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: bash
Version: 3.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-11-29 16:54 UTC by John P. bland
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-11-29 17:16:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description John P. bland 2004-11-29 16:54:59 UTC
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 16:57:13 UTC
in expected results the variable x2 should be set to the listed data

Comment 2 Tim Waugh 2004-11-29 17:16:21 UTC
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.