On Mon Aug 19 15:37:24 EDT 2013, cinap_len...@gmx.de wrote: > x=foo; @{x=bar}; echo `{cat /env/x} > > yields "foo" but > > x=foo; echo; @{x=bar}; echo `{cat /env/x} > > yields "bar" > > the problem is that the environment variables are > only flushed to /env on exec, but not on fork. > > in the first example, after executing the > subshell, x is still marked as "modified" by > us and the cat/echo will cause the old value > to be flushed and the changed value from the > subshell be overridden. > > havntfork.c does flush the variables on fork tho. > > i think it would be more consistent todo this for > havefork.c as well. > > is there a good reason not to?
here are three reasons. i am not sure if any of them are good - it is going to be nearly impossible to tell if this behavior is depended on somewhere. - it also potentially has performance implications. - subshells can also run asynchronous, asynchronously modifying the environment. don't we still have a race? - erik