bug-bash
[Top][All Lists]
Advanced

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

Re: inconsistency with "readonly" and scope


From: dethrophes
Subject: Re: inconsistency with "readonly" and scope
Date: Thu, 12 Apr 2012 20:16:37 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

Am 12.04.2012 14:27, schrieb Chet Ramey:
On 4/11/12 4:12 PM, dethrophes wrote:

I've also noticed weird behavior with "declare -gr" the r sometimes seems
to override the g, but not specific to functions It seems to be specific
either to the source file or to the compound statement. I haven't been able
to figure out exactly whats going on there. I haven't been able to
reproduce it in a simple example. this is most readily noticeable with set
-o nounset
An example would help.  The above is supposed to create a global readonly
variable.  I suspect that you see the `global' as being `overridden'
because it's being created in a subshell environment.

Chet



I only see the problem in large complex cases, I've tried to reproduce a simple example a couple of times but without success.
no its not a subshell problem, I avoid subshells as much as possible.
also when I expereimented with the problem a couple of times I discovered the following-
declare -g                     works
declare -gr                     doesn't work
my current workaround is I've just stopped using the readonly attribute which works. or just stopped using declare altogether.
or do something like this
var=x
typeset -r var

I've also seen some strange behavior with
declare in a conditional sourced global context. it only seems to happen when the code size is 10000s+ lines long. I think this is exasperated by the fact that i source my files inside conditional statements. the result is that I now even in a global context set the global flag.

any ideas what could be causing it would help me try to figure out how to test for it.

Sorry about the weak description but I've been working around it now for months waiting for it to make sense and I'm no closer to figuring out whats going on. the problem is so erratic it has to be some sort of partial lost context or something.

can you give me any tips on how to debug it if I can reproduce it again? is their an easy way to track the validity of a variable?









reply via email to

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