[NTLUG:Discuss] scope of variables in bash scripts

Fred James fredjame at concentric.net
Wed Aug 8 07:57:03 CDT 2001


Sorry to trouble - I wrote a small sample to illustrate the problem, but
it worked as expected, so I guess I will have to dig a little deeper
into my original problem.
Thank you for your reply.

Richard Cobbe wrote:
> 
> Lo, on Tuesday, August 7, Fred James did write:
> 
> > My experience with sh (Bourne) is that a variables within a file have the
> > scope of the file.  I am finding this is not true in bash, at least on
> > Red Hat Linux 7.1 Variables assigned values within a while loop revert to
> > there values, if any, before the loop was entered.
> >
> > Am I missing something?  Is there a way to make a variable have the scope
> > of the file?
> 
> My understanding was that all variables are essentialy global, as you say.
> Could you post a short example of code that's not working as you expect?
> 
> Richard
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss

-- 
...make every program a filter...



More information about the Discuss mailing list