On Wed, Apr 3, 2013 at 11:50 AM, Chris F.A. Johnson <ch...@cfajohnson.com>wrote
>
>   Still Nikolai has a point.
>>>>>
>>>>
>  It's not clear why readonly variable can be overridden when the
>>>> variable is declared readonly in the scope of an englobing
>>>> function but not if it is declared readonly in the global scope.
>>>>
>>>
>>>    If it's declared readonly in a function, the variable doesn't exist
>>>    outside of that function, so it's not readonly there.
>>>
>>
>> I think you missed the point that "a" is called inside "b".
>> See the example below
>>
>>   $ bash -c 'a() {  v=2;echo "$v"; }; b () { declare -r v=1; a; echo "$v";
>>>
>>>> };
>>>> b'
>>>> bash: v: readonly variable
>>>>
>>>
>> if v doesn't exist in "a" why does it complain that it's readonly?
>>
>
>    It *does* exist inside a() if a() is a child of b().


.... yes, and it's readonly, but you can redeclare it locally, something
you can't do with a readonly global variable.

Reply via email to