On 2/12/18 1:41 AM, Nikolai Kondrashov wrote:
> Hi Chet,
> 
> On 02/12/2018 01:31 AM, Chet Ramey wrote:
>> On 2/11/18 1:06 PM, Nikolai Kondrashov wrote:
>>> Hi everyone,
>>>
>>> I think I'm hitting a bug in Bash 4.4.12 (on Debian Stable): at some point
>>> an "unset" of a global array variable doesn't work inside a function, in
>>> "dkms" script from DKMS package. Adding another "unset" of the same
>>> variable
>>> next to it fixes the issue.
>>
>> Do you have a local variable with the same name "shadowing" the global?
> 
> Thank you for the quick response!
> 
> Looking more into this, the variable in question is defined as a local in the
> calling function and is being "unset" in a function called from that one.

This is bash's dynamic scoping. The visibility of a local variable is
restricted to a function and its children, and `unset' removes the
currently-visible instance. Removing such an instance can `unconver' an
instance in a previous scope.

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

Reply via email to