Benjamin Goldberg <[EMAIL PROTECTED]> writes: > Lars Balker Rasmussen wrote: >> However, now the 4th test fails on Solaris (and most likely other OS's >> witout setenv/unsetenv). This is because the test relies on a key >> disappearing from %ENV when it's been unsetenv'ed - this doesn't >> happen when using putenv("key=") as the current unsetenv emulation. >> >> I'm not sure what's the best portable way to handle this is. > > a) Have config test for the existance of extern char **environ, or > possibly for extern char **_environ, and then emulate unsetenv by > mangling the contents of that variable.
That's what perl5.8.0 (util.c:Perl_my_setenv) seems to prefer. But if PERL_USE_SAFE_PUTENV is defined it falls back to putenv("foo=") for clearing foo, which is what we do at the moment. So as far as I can tell, the perl5 semantics is that you can't rely on "delete $ENV{foo}" removing the key "foo" from %ENV... Dan? > b) Use a hash to keep track of which keys we have deleted from %ENV. > When we want to know if a key exists in %ENV, first try to getenv() it, > and if it's an empty string (""), see if it's mentioned in the hash of > things we deleted from %ENV: if so, *claim* that the key doesn't exist. Eek, that's just plain nasty :-) -- Lars Balker Rasmussen Consult::Perl