Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: new user questions and issues



On May 11, 10:43am, Kannan Varadhan wrote:
}
} What I really desire is that the variable not be inherited by or
} visible to any called functions.

That's pretty much never going to work.  The shell parameter space uses
dynamic scoping starting from the process environment on down; a scope
can explicitly replace a name from its surrounding scope, but can't
conceal that name from scopes upon which it calls.

In fact because shell functions can only accept arguments and can only
return exit status, dynamically scoped variables are the only way to
share data from a called function.  (Except stdin and stdout, of course,
but then you're dealing with separate processes, not merely scopes.)

Yes, ksh plays some games with this by allowing a nameref to be passed
as an argument.



Messages sorted by: Reverse Date, Date, Thread, Author