Global variables, and their scope in Bash.

NoOp glgxg at sbcglobal.net
Mon Dec 14 02:43:48 UTC 2009


On 12/13/2009 06:24 PM, Ray Parrish wrote:
> NoOp wrote:
>> On 12/13/2009 04:22 PM, Ray Parrish wrote: ...
>> 
>>> Does anyone have any light they can shed on the behavior of
>>> global variables in Bash?
>>> 
>>> Thanks, Ray Parrish
>>> 
>>> 
>> 
>> Perhaps these will help: http://tldp.org/LDP/abs/html/ 
>> http://tldp.org/LDP/Bash-Beginners-Guide/html/ 
>> http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html
>> 
> Thanks for the references. I've been using the Advanced Bash
> Scripting manual, and I could not find anywhere that it talked about
> globals.
> 
> According to the third link you gave, a global variable may not be
> modified by a subshell, which defeats the actual purpose of a global
> variable as it was understood by me. If I cannot modify it's value so
> that altered value can be available to another function, what good is
> it anyway?
> 
> I take it then that each of my functions is a "subshell", so the
> value of a global variable would not be alterable by any of them?
> 
> Thanks, Ray Parrish
> 
> 
> 

Don't know (sorry), but the link for the shell list might have answers:
http://www2.codegnome.org:59321/cgi-bin/mailman/listinfo/shell.scripting





More information about the ubuntu-users mailing list