On 2/23/11 8:36 AM, Nardmann, Heiko wrote:
> Hi together,
> 
> short: is there any way to get informed about unset local variable while
> having option 'nounset' activated?
> 
> Long: the problem with 'local' is that variable declared this way are
> visible inside the children, too. So the behaviour of option 'nounset'
> depends on the way a function is called - either with a caller function
> with the (locally) unset variable already set or without one.

Yes.  This is a consequence of bash's dynamic scoping.

I'm not sure I understand your question.  Your example script demonstrates
one of the properties of dynamic scoping: a function can find variables
up the call chain all the way to the global variable context.

If your question is whether or not the call to `g' can result in an unset
variable error even though f has a local copy already declared, the answer
is no.  That is ksh93-style static scoping, and bash does not have it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to