On 1/23/12 2:58 PM, Denis Melnikov wrote:
> Hi,
> after the following fragment of code named variable gets empty:
>
> ls | while read file ; do
> v=1
> break
> done
> echo $v
>
> Is it a bug or a feature?
> GNU bash, version 4.1.2(1)-release
All components of a pipeline generally run in separate processes. A
child process can't affect its parent. If you upgrade to bash-4.2, look
at the `lastpipe' option to run the last component in the parent shell
process.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/