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.

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Local variable names clash with global read-only variable names.
Date Tue, 28 Apr 2020 14:28:18 -0400
Lines 18
Approved bug-bash@gnu.org
Message-ID <mailman.1512.1588098753.3066.bug-bash@gnu.org> (permalink)
References <courier.000000005EA87284.0001EE9C@charon.podzimek.org> <20200428182818.GL845@eeg.ccf.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1588098754 1233 209.51.188.17 (28 Apr 2020 18:32:34 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To andrej@podzimek.org
Envelope-to bug-bash@gnu.org
Mail-Followup-To andrej@podzimek.org, bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <courier.000000005EA87284.0001EE9C@charon.podzimek.org>
User-Agent Mutt/1.10.1 (2018-07-13)
Received-SPF none client-ip=139.137.100.1; envelope-from=wooledg@eeg.ccf.org; helo=mail.eeg.ccf.org
X-detected-operating-system by eggs.gnu.org: First seen = 2020/04/28 14:28:19
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 139.137.100.1
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20200428182818.GL845@eeg.ccf.org>
X-Mailman-Original-References <courier.000000005EA87284.0001EE9C@charon.podzimek.org>
Xref csiph.com gnu.bash.bug:16256

Show key headers only | 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