[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
variable lost when while loop piped
From: |
ecashin |
Subject: |
variable lost when while loop piped |
Date: |
Fri, 01 Jun 2007 18:02:30 -0400 |
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' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g -O2
uname output: Linux kokone 2.6.15.1 #8 SMP Thu Feb 15 15:39:10 EST 2007 i686
GNU/Linux
Machine Type: i686-pc-linux-gnu
Bash Version: 3.2
Patch Level: 0
Release Status: release
Description:
A variable set inside a while loop loses its value if
the while loop is piped to a command, e.g., sed.
Repeat-By:
ecashin@kokone ~$ seq 0 9 | ~/build/bash-3.2/bash -c 'while read a; do
last=$a; done | cat; echo :$last:'
::
ecashin@kokone ~$ seq 0 9 | ~/build/bash-3.2/bash -c 'while read a; do
last=$a; done; echo :$last:'
:9:
- variable lost when while loop piped,
ecashin <=