On Jan 8 2009, Dean Brooks wrote:
I found similar code implementing unsetenv() in a perl module that seems to do the same thing. Completely untested, but example follows.
void env_remove(const char *name) { int name_len; extern char **environ; char **envp;
name_len = strlen(name); for (envp = environ; *envp != NULL; envp++) { if (strncmp(name, *envp, name_len) == 0 && (*envp)[name_len] == '=') { free(*envp); do { envp[0] = envp[1]; } while (*envp++); break; } } }
At the UofMN we tried some things like this that didn't seem to quite do the trick, so in the end we just built on a Solaris 10 machine with proper unsetenv and ran that binary on 9. Might work for 8 too. Not recommended, but.... :)
-- Brian Hayden Minnesota Supercomputing Institute University of Minnesota