[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: Chet Ramey
Subject: Re: typeset -r prevents local variable of same name.
Date: Wed, 16 Feb 2011 22:13:56 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7

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.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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