[Top][All Lists]

[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: 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, address@hidden 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 
>> -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 #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   address@hidden    +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]