[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Variable undefines - bug or feature?
From: |
DJ Mills |
Subject: |
Re: Variable undefines - bug or feature? |
Date: |
Mon, 23 Jan 2012 15:00:33 -0500 |
On Mon, Jan 23, 2012 at 2:58 PM, Denis Melnikov <dbmelnikov@gmail.com> 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
>
> Denis
>
Pipelines create subshells. See http://mywiki.wooledge.org/BashFAQ/024
As an aside, never parse ls. Simply use a glob.