help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Closure concept in bash


From: Chet Ramey
Subject: Re: [Help-bash] Closure concept in bash
Date: Tue, 31 Jan 2012 22:59:58 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 1/31/12 5:18 PM, Ken Irving wrote:

> Another thing to note is that bash uses dynamic vs the more common static
> scoping for variables, e.g., see this thread:

I'm not sure how much more common static scoping is in this context.  Given
the following script:

foo()
{
        local bar

        bar=inside
        foo2
}

foo2()
{
        echo $bar
}

bar=outside
foo
echo $bar

bash, mksh, zsh, dash, and the FreeBSD 8 sh all print `inside', then
`outside'.  ksh93 (after making the appropriate modifications to the
script syntax), is the only one that prints `outside' and `outside'.

Chet
-- 
``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]