[Top][All Lists]

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

Local variables overriding global constants

From: Nikolai Kondrashov
Subject: Local variables overriding global constants
Date: Wed, 03 Apr 2013 10:14:44 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

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() { declare -r v; }; a'

Results in:

    bash: line 0: declare: v: readonly variable

While this works:

    bash -c 'a() { declare -r v; }; b() { declare -r v; a; }; b'

Thank you.


reply via email to

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