From: Jim I. <ji...@ap...> - 2002-03-01 18:23:07
|
James, Thanks for tracking this down! I bet nobody ever really tested changing the environment on Classic MacOS very thoroughly, since it really didn't have all that much use. The main use of the environment is either to get stuff passed in to you from your parent which doesn't require changing the environment, or to affect the state of any child processes, which you couldn't have on classic MacOS. When you send the patch, I'll get it right in. Jim On Friday, March 1, 2002, at 06:44 AM, James Bonfield wrote: > On Thu, Feb 28, 2002 at 11:33:08AM -0800, Jim Ingham wrote: >> James, >> >> I did notice this when I was playing around just yesterday. It is odd, >> because it mostly works just fine, and then every so often you will get >> the "can't read..." error, or it will just silently fail to set the >> environment. Then one or two commands later it will work again. >> Please >> file a bug on this, and if you want to have a whack at it, that would >> be >> great. It is a pretty annoying bug. > > I've tracked down the cause of the bug and a possible solution, > although I > need to experiment further. > > TclSetupEnv has: > > environ = *_NSGetEnviron(); > > When adding an environment variable we need to extend environ, which is > done > using ckalloc and memcpy. However an array names or similar function > will > recall TclSetupEnv and so throws away our extended copy. Even if it > didn't > call TclSetupEnv we'd still have problems for subprocesses as we haven't > actually changed the environment, we've just made a copy. > > So just after the reallocate I added: > > char ***e = _NSGetEnviron(); > *e = environ; > > and lo the problem has vanished! I'm guessing that this has nothing at > all to > do with MacOS X, but to do with the earlier mac versions too. I admit > that I > was a little suprised I could change the environment just like that, > but I'm > happy I can. > > I'll produce a patch and submit this to sourceforge. > > James > > -- > James Bonfield (jk...@mr...) Fax: (+44) 01223 213556 > Medical Research Council - Laboratory of Molecular Biology, > Hills Road, Cambridge, CB2 2QH, England. > Also see Staden Package WWW site at http://www.mrc-lmb.cam.ac.uk/pubseq/ > > _______________________________________________ > Tcl-mac mailing list > Tc...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-mac > -- Jim Ingham ji...@ap... Developer Tools - gdb Apple Computer |