Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16256

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

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Local variable names clash with global read-only variable names.
Date 2020-04-28 14:28 -0400
Message-ID <mailman.1512.1588098753.3066.bug-bash@gnu.org> (permalink)
References <courier.000000005EA87284.0001EE9C@charon.podzimek.org> <20200428182818.GL845@eeg.ccf.org>

Show all headers | View raw


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.

If the end user were able to change it simply by declaring it as local
inside a function, breaking the restricted shell would be too easy.

(The fact that restricted shells are a joke doesn't change this stance.)

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Local variable names clash with global read-only variable names. Greg Wooledge <wooledg@eeg.ccf.org> - 2020-04-28 14:28 -0400

csiph-web