Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Greg Wooledge 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: References: <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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20200428182818.GL845@eeg.ccf.org> X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:16256 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.)