bug-bash
[Top][All Lists]
Advanced

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

Re: Local variables overriding global constants


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

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:

    2



reply via email to

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