bug-bash
[Top][All Lists]
Advanced

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

Re: Variable scope problem in nested loops?


From: Chet Ramey
Subject: Re: Variable scope problem in nested loops?
Date: Wed, 15 Sep 2004 13:56:10 -0400

> Machine Type: i686-pc-linux-gnu
> 
> Bash Version: 3.0
> Patch Level: 0
> Release Status: release
> 
> -----------------------------------------------------------------------
> 
> Description:
>       I can set or change the value of a variable inside a for loop which
> is in turn inside a while loop, but the changes are lost when accessing =
> the
> variable after outside the loops. See script below.

Each element of a pipeline is run in a separate subshell.  The answer to
question E4 in the bash FAQ explains this in more detail.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                                Live...Laugh...Love
Chet Ramey, ITS, CWRU    address@hidden    http://tiswww.tis.cwru.edu/~chet/




reply via email to

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