bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Local variable names clash with global read-only variable names.


From: Chet Ramey
Subject: Re: Local variable names clash with global read-only variable names.
Date: Thu, 30 Apr 2020 18:53:44 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/28/20 2:28 PM, Greg Wooledge wrote:
> On Tue, Apr 28, 2020 at 08:14:28PM +0200, andrej--- via Bug reports for the 
> GNU Bourne Again SHell wrote:
>>     f() { local x=a; }
>>     declare -r x
>>     f  # bash: local: x: readonly variable
>>
>>   This^^^ should not fail; it hinders reusability of shell functions and 
>> makes
>>   them context-dependent.
> 
> The purpose of 'readonly' as a variable attribute is to supplement a
> restricted shell environment.  If a variable is set readonly, it's because
> the system administrator, or whoever set up the enviroment, demands that
> this variable NOT be changed by the end user.

The second sentence is true, but extends beyond the restricted shell
environment. Variables are readonly for a reason.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]