On Wed, 3 Apr 2013, Nikolai Kondrashov wrote:
Hi everyone,
It seems Bash 4.2.37 doesn't allow functions to redefine global constants
locally, yet it allows redefining constants local to calling functions.
Is this as supposed to be, or is it a bug?
I.e. this:
bash -c 'declare -r v; a() {
On 04/03/2013 10:43 AM, Chris F.A. Johnson wrote:
On Wed, 3 Apr 2013, Nikolai Kondrashov wrote:
I.e. this:
bash -c 'declare -r v; a() { declare -r v; }; a'
Results in:
bash: line 0: declare: v: readonly variable
It doesn't work because you are trying to redefine an existing
readonly
It works because both instances are local to a function and don't
exist outside their own functions.
Not true.
This:
bash -c 'a() { echo $v; }; b() { declare -r v=123; a; }; b'
Produces this:
123
Moreover, this:
bash -c 'a() { v=2; }; b () { v=1; a; echo $v; }; b'
Produces this:
On 2013-04-03 10:50, Nikolai Kondrashov wrote:
On 04/03/2013 10:43 AM, Chris F.A. Johnson wrote:
On Wed, 3 Apr 2013, Nikolai Kondrashov wrote:
I.e. this:
bash -c 'declare -r v; a() { declare -r v; }; a'
Results in:
bash: line 0: declare: v: readonly variable
It doesn't work because
On 04/03/2013 10:53 AM, Nikolai Kondrashov wrote:
Moreover, this:
bash -c 'a() { v=2; }; b () { v=1; a; echo $v; }; b'
Sorry, forgot declare, should be this instead:
bash -c 'a() { v=2; }; b () { declare v=1; a; echo $v; }; b'
Sincerely,
Nick
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It doesn't work because you are trying to redefine an existing
readonly variable.
Yes, but I'm explicitly redefining it locally, only for this function.
And this works for variables previously defined in the calling function.
You're not
On Wed, 3 Apr 2013, Nikolai Kondrashov wrote:
On 04/03/2013 10:53 AM, Chris Down wrote:
On 2013-04-03 10:50, Nikolai Kondrashov wrote:
On 04/03/2013 10:43 AM, Chris F.A. Johnson wrote:
On Wed, 3 Apr 2013, Nikolai Kondrashov wrote:
I.e. this:
bash -c 'declare -r v; a() { declare -r v; }; a'
On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote:
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It doesn't work because you are trying to redefine an existing
readonly variable.
Yes, but I'm explicitly redefining it locally, only for this function.
And this
On Wed, Apr 3, 2013 at 11:21 AM, Pierre Gaston pierre.gas...@gmail.comwrote:
On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote:
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It doesn't work because you are trying to redefine an existing
readonly variable.
Yes,
On Wed, 3 Apr 2013, Pierre Gaston wrote:
On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote:
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It doesn't work because you are trying to redefine an existing
readonly variable.
Yes, but I'm explicitly redefining it locally,
On Wed, Apr 3, 2013 at 11:33 AM, Chris F.A. Johnson ch...@cfajohnson.comwrote:
On Wed, 3 Apr 2013, Pierre Gaston wrote:
On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote:
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It doesn't work because you are trying to
Chris Down, Chris F.A. Johnson and Pierre Gaston,
thank you all for quick replies!
I now see that this is a known behavior and is considered normal by
developers.
Although, I'd say that it feels unnatural.
On 04/03/2013 11:26 AM, Pierre Gaston wrote:
ok it has indeed been discussed, and
On Wed, 3 Apr 2013, Pierre Gaston wrote:
On Wed, Apr 3, 2013 at 11:33 AM, Chris F.A. Johnson ch...@cfajohnson.comwrote:
On Wed, 3 Apr 2013, Pierre Gaston wrote:
On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote:
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It
On Wed, Apr 3, 2013 at 11:50 AM, Chris F.A. Johnson ch...@cfajohnson.comwrote
Still Nikolai has a point.
It's not clear why readonly variable can be overridden when the
variable is declared readonly in the scope of an englobing
function but not if it is declared readonly in the global
On 4/3/13 4:21 AM, Pierre Gaston wrote:
On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote:
On 2013-04-03 11:00, Nikolai Kondrashov wrote:
It doesn't work because you are trying to redefine an existing
readonly variable.
Yes, but I'm explicitly redefining it locally,
On Wednesday 03 April 2013 09:34:18 Chet Ramey wrote:
A variable is declared readonly for a reason, and, since readonly variables
may not be assigned to, I don't believe you should be able to override a
readonly variable by declaring it local to a function. I did, however
reluctantly, allow a
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 4/3/13 12:31 PM, Mike Frysinger wrote:
sounds like the fundamental limitation is that the person writing the code
can't declare their intentions. after your compromise, they now can. if you
follow the convention of putting all code into a
On Wednesday 03 April 2013 21:38:19 Chet Ramey wrote:
On 4/3/13 12:31 PM, Mike Frysinger wrote:
sounds like the fundamental limitation is that the person writing the
code can't declare their intentions. after your compromise, they now
can. if you follow the convention of putting all code
18 matches
Mail list logo