On 3/19/17 6:22 PM, Stephane Chazelas wrote:

>> $ cat x2
>> function foo
>> {
>> (
>>      unset -v IFS
>>      recho "${IFS-unset}"
>> )
>> }
>>
>> IFS=':|'
>> foo
>> echo after IFS = "$IFS"
>> $ ../bash-4.4-patched/bash ./x2
>> argv[1] = <unset>
>> after IFS = :|
> 
> Yes, that one is  fine but it is not the issue that is being
> discussed here. There's no variable to pop off a stack above.
> 
> the issue is when that "foo" function is called in a context
> where IFS had been declared locally. Like in:
> 
> IFS=1
> function example {
>   typeset IFS=2
>   foo
> }
> 
> Where "foo" would output "1", because then "unset -v IFS" would
> *not* have unset IFS but instead would have restored the value
> it had before the "typeset" (in that case, the global scope).
> 

Yeah, that's how local variables and dynamic scoping in bash have always
worked.  That ship really has sailed.

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

Reply via email to