Path: utzoo!attcan!uunet!mcvax!botter.cs.vu.nl!star.cs.vu.nl!sjoerd From: sjoerd@cs.vu.nl (Sjoerd Mullender) Newsgroups: comp.sources.bugs Subject: Re: Jove bug Message-ID: <734@sjoerd.cs.vu.nl> Date: 18 May 88 08:51:22 GMT References: <321@syntron.UUCP> <4071@killer.UUCP> Reply-To: sjoerd@cs.vu.nl (Sjoerd Mullender) Organization: VU Informatica, Amsterdam Lines: 27 In article <4022@killer.UUCP> elg@killer.UUCP (Eric Green) writes: [ describes that Jove 4.9 believes the value of the PWD environment variable ] In article <4071@killer.UUCP> elg@killer.UUCP (Eric Green) writes: >I "solved" the problem simply by commenting out the getenv("CWD") and >getenv("PWD") calls, and falling through into the getcwd() call. But that's no >permenant solution. Perhaps we need an #ifdef NOENV or something like that >(gawd, yet another variable in tune.h!). A better solution would be to check the value returned by getenv("CWD") or getenv("PWD"). This is very easily done as follows: You stat the result of the getenv() call. If stat fails then the value was wrong and you call getcwd(). If the stat succeeds you also stat ".". Then you compare the device and the inode values in both stat structures to see if they are the same. If not, call getcwd(). If they *are* the same then $CWD/$PWD pointed to the current directory (posibly via symbolic links, but that isn't too bad). If $CWD/$PWD is correct this will cost 2 extra calls to stat(). Not a very large performance penalty. > Eric Lee Green {cuae2,ihnp4}!killer!elg > Snail Mail P.O. Box 92191 Lafayette, LA 70509 -- Sjoerd Mullender sjoerd@cs.vu.nl When this doesn't work try sending via uunet.uu.net or mcvax.uucp.