[erlang-patches] Add os:unsetenv/1

Martin Hässler <>
Sat Oct 26 21:30:26 CEST 2013

This patch adds os:unsetenv/1 which deletes an environment variable.

### Why this new feature?

With os:unsetenv/1, it is possible to delete environment variables.
This makes it easier to test code which uses os:getenv/1 to check if
an environment variable exists or not. The new function differs from
os:putenv(Value, "") as the former deletes the variable while the
latter keeps the variable with an empty value.


  1> os:putenv("foo", "").
  2> os:getenv("foo").
  3> os:unsetenv("foo").
  4> os:getenv("foo").

### Risks / uncertain artifacts

None. New function without any changes in old functionality.

### How did you solve it?

New BIF which calls the libc function unsetenv(3) on UNIX and
SetEnvironmentVariableW(key, NULL) on Windows. The unicode support is
the same as for os:getenv and os:putenv.


Best Regards,

More information about the erlang-patches mailing list