[Top][All Lists]

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

Re: Variable undefines - bug or feature?

From: Chet Ramey
Subject: Re: Variable undefines - bug or feature?
Date: Mon, 23 Jan 2012 19:41:48 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

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


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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