bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in bash v2.05b


From: Philippe Berthault
Subject: bug in bash v2.05b
Date: Thu, 5 Dec 2002 14:57:10 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib -D_GNU_SOURCE  -O2 -march=i386 -mcpu=i686
uname output: Linux frcls2015 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux
Machine Type: i686-pc-linux-gnu
 
Bash Version: 2.05b
Patch Level: 0
Release Status: release
 
Description:
========
  The command like in "liste | while read variable" doesn't work correctly.
 
Repeat-By:
=======
   See script example below.
 
Script example:
===========
flag=INITIAL
echo "initial flag = $flag  Pid= $$"
echo
 
echo "1
      2
      3" | while read var
do
   echo "old flag = $flag  Pid= $$"
   flag="MODIFIED($var)"
   echo "new flag = $flag  Pid= $$"
done
echo
echo "final flag = $flag  Pid= $$"
Problem:
======
The script returns:
 
initial flag = INITIAL  Pid= 6547
 
old flag = INITIAL  Pid= 6547
new flag = MODIFIED(1)  Pid= 6547
old flag = MODIFIED(1)  Pid= 6547
new flag = MODIFIED(2)  Pid= 6547
old flag = MODIFIED(2)  Pid= 6547
new flag = MODIFIED(3)  Pid= 6547
 
final flag = INITIAL  Pid= 6547
 
As you can see, the final flag is false.
The same script using ksh on a AIX system gives the correct result,
so bash and ksh are not compatibles.
 
Fix:
==
 To fix the problem, I uses the "for var in" instead of " | while".
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]