bug-bash
[Top][All Lists]
Advanced

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

Re: typeset -r prevents local variable of same name.


From: Eric Blake
Subject: Re: typeset -r prevents local variable of same name.
Date: Thu, 17 Feb 2011 10:11:56 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Red Hat/3.1.7-3.el6_0 Mnenhy/0.8.3 Thunderbird/3.1.7

On 02/16/2011 08:13 PM, Chet Ramey wrote:
> On 2/13/11 3:17 PM, steveo@syslang.net wrote:
>> Configuration Information [Automatically generated, do not change]:
>> Machine: i386
>> OS: linux-gnu
>> Compiler: gcc
>> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
>> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
>> -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
>> -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE 
>> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall 
>> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
>> --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
>> -fasynchronous-unwind-tables
>> uname output: Linux saturn.syslang.net 2.6.27.41-170.2.117.fc10.i686.PAE #1 
>> SMP Thu Dec 10 10:48:30 EST 2009 i686 athlon i386 GNU/Linux
>> Machine Type: i386-redhat-linux-gnu
>>
>> Bash Version: 3.2
>> Patch Level: 39
>> Release Status: release
>>
>> Description:
>>      First, I already submitted this bug from work, but I didn't
>>  realize that the address I sent from would not be allowed to receive
>>  a response. This address will work fine.
>>
>> If I declare a variable at the top scope using -r, it will prevent me
>> from declaring a local copy in a subroutine. This problem happens in
>> this version of bash as well as in bash4 under Fedora 14.
> 
> This is intentional.  A variable is declared readonly for a reason, and
> readonly variables may not be assigned to.  I don't believe that you
> should be able to use a function to circumvent this.

Consensus on today's Austin Group meeting was that since we are
interested in standardizing local variables (or at least a subset of the
'typeset' special built-in's capabilities), this needs to be uniform
across implementations.  The Austin Group would favor the ability to
create a local read-write variable that shadows a global read-only
variable, which would entail a change to this bash behavior.

[Which reminds me - I still have the action item to propose wording for
getting typeset into the next revision of POSIX]

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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