tech-userlevel archive

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

Re: bin/47597: local and $() don't play well with each other



On Tue, Feb 26, 2013 at 10:31:03PM +0700, Robert Elz wrote:
> But they didn't, they added the text in 2.9.5 that makes function execution
> behave like a special built-in for the purposes of variable assignments
> (and syntax errors, but that's not relevant here.)   The only possible
> reason for doing that is to make var assignments on function executions
> persist into the current environment, just like they do with special 
> built-ins,
> as insane as that is.   That ksh implements it this way is further evidence
> that this is what was intended (and most likely the cause of this intent.)

Another thing to remember is that variable assignments inside
functions affect the calling shell script.

This (sort of) implies and is implied by the fact that shell functions
are executed without a fork() (as are all 'special builtins'.
So there is no alternate (child) namespace for those (environment)
variable assignments to be done in.
Hence they persist in the script.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index