Add os:unsetenv/1

Martin Hässler <[email protected]>
Newsgroups gmane.comp.lang.erlang.patches
Message-ID <CACy-PPo9NP8tgG5hL6VvhL_-TrQqQcNHKREhr3-ymfFP9S_jjw@mail.gmail.com>
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.

Example:

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

### 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.


https://github.com/erlang/otp/pull/114

-- 
Best Regards,
/Martin
_______________________________________________
erlang-patches mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.