bug-bash
[Top][All Lists]
Advanced

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

Re: [bash 4.2] `declare -g' bug?


From: Chet Ramey
Subject: Re: [bash 4.2] `declare -g' bug?
Date: Fri, 18 Feb 2011 06:48:07 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7

On 2/17/11 10:25 PM, Clark J. Wang wrote:
> On Fri, Feb 18, 2011 at 8:45 AM, Chet Ramey <chet.ramey@case.edu
> <mailto:chet.ramey@case.edu>> wrote:
> 
> 
>     The -g option exists solely to create variables at the global scope.  The
>     intent is that functions be able to declare global variables with
>     attributes if they desire.  It doesn't change the scoping rules or
>     variable resolution behavior.
> 
> 
> A global var can always be declared out of a func (usually at the beginning
> of the script) so what's the main intention of introducing a new `-g' option?

As I said, so functions can declare global variables with attributes.

> And If we can declare/modify a global var in a func but we cannot read it
> from in the func I don't think the feature is very useful to people.

There are more things in heaven and earth than are dreamt of in your
philosophy.  How about you and I want until the folks who requested
the feature weigh in on the subject.

(And keep in mind that you can read a global variable from a function just
fine as long as you don't interpose another local variable with the same
name from a different function.)

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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