[Top][All Lists]

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

Re: about the local not-on-every-function-separately var issue

From: Dale R. Worley
Subject: Re: about the local not-on-every-function-separately var issue
Date: Mon, 22 Mar 2021 21:38:37 -0400

Greg Wooledge <greg@wooledge.org> writes:
> Now, the big question is WHY you thought something which is not correct.
> The most common reasons that people think something which is wrong are:

In my experience, a common reason is that the documentation does not
concentrate in one place that users are certain to read, a complete,
clear description of the situation.  For instance, you give a complete,
clear description:

    Bash uses "dynamic scope" when it expands variables.  This means that
    it looks first in the current functions local variables; if the variable
    isn't found there, it looks in the caller's local variables, and then
    in the caller's caller's local variables, and so on, until it reaches
    the global scope.

And that behavior is implied if you read the definition of "local"
closely.  But I couldn't find any text in the manual page that states
that directly.  (*Very* closely, as the text refers to "the function and
its children".  But function definitions don't nest; what it means is
"the function *invocation* and its child invocations.)  In principle it
should be stated at the point where parameter expansion is introduced,
as it is the *definition* of what parameter expansion does.


reply via email to

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