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. 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). -- Dan Douglas