Jove bug

Sjoerd Mullender sjoerd at cs.vu.nl
Wed May 18 18:51:22 AEST 1988


In article <4022 at killer.UUCP> elg at killer.UUCP (Eric Green) writes:
[ describes that Jove 4.9 believes the value of the PWD environment variable ]

In article <4071 at killer.UUCP> elg at 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 at cs.vu.nl
When this doesn't work try sending via uunet.uu.net or mcvax.uucp.



More information about the Comp.sources.bugs mailing list