[prev in list] [next in list] [prev in thread] [next in thread]
List: bash-bug
Subject: Re: 'local -x VARIABLE' does not clear variable for subprocesses
From: Chet Ramey <chet.ramey () case ! edu>
Date: 2014-05-07 20:36:07
Message-ID: 536A9937.7020505 () case ! edu
[Download RAW message or body]
On 5/7/14, 11:43 AM, Dan Douglas wrote:
> On Wednesday, May 07, 2014 10:04:11 AM Chet Ramey wrote:
>> On 5/7/14, 2:10 AM, Dan Douglas wrote:
>>> By "doesn't shadow" you mean that it _does_ hide the global right? Localizing
>>> a variable should cover up globals and variables in parent scopes even if they
>>> aren't given a value. That seems true in bash 4.3 and nearly every shell
>>> (except dash).
>>
>> I mean that a local variable that has not been given a value, and is
>> technically unset, should not shadow a global variable with the same
>> name. Run the following script, after accounting for the local/typeset
>> differences between shells. The results are less conclusive than you think.
>
> Ah ok I thought you meant the opposite. So not the "dash effect" where
> the value of a global is always still visible until a local gets a
> value.
No, that's what I'm talking about. The local is unset until it gets a
value, so the global is still visible (not shadowed).
This is not what bash-4.3 does, but I was thinking about experimenting
with a change to make bash-4.3 behave like ksh93 and dash. I put some
code in so I can call different functions in the `find_variable' family
to get different behavior, so I will experiement that way.
> Yes I see the results are all over the place. Basically what the big
> script linked in my previous post attempted to test, though ksh lexical
> scope makes comparison hard and not so meaningful. Your bash 4.3 way
> makes sense to me (leaving the global in the environment but shadowing
> the local).
It makes sense if you know the internals and what's going on, but it's
kind of difficult to explain.
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/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic