BASH question

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Tue Dec 18 01:32:03 UTC 2007


On Mon, Dec 17, 2007 at 01:54:21PM -0500, Brandon Sandrowicz wrote:
> ...
> Why have him creating two scripts just to pipe one to the other?
> 
> command | while read LINE
> do
>    do something w/ $LINE
> done
> 
> The only problem that I've had is that when setting array values
> inside of the array, they remain local to the loop for some reason...
> even when you declare the array outside of the loop.

That's because commands in a pipe are executed in subshells (ie.
separate processes).  So, any change to childs' environments will not
propagate up to the parent.

-- 
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>, Toronto, Canada
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list