diff options
author | Martin Hässler <[email protected]> | 2013-11-09 21:04:06 +0100 |
---|---|---|
committer | Martin Hässler <[email protected]> | 2013-11-09 21:04:06 +0100 |
commit | 7b739330bb459401f9c11f0f84912aedc7ee22cd (patch) | |
tree | e1ffbca9adb63a1132c6c8af8236b725a8c5da56 /lib/kernel | |
parent | 768a64354e3d69b3c0840a84dd072601c67ca39d (diff) | |
download | otp-7b739330bb459401f9c11f0f84912aedc7ee22cd.tar.gz otp-7b739330bb459401f9c11f0f84912aedc7ee22cd.tar.bz2 otp-7b739330bb459401f9c11f0f84912aedc7ee22cd.zip |
Add os:unsetenv/1
New BIF os:unsetenv/1 which deletes an environment variable and
returns 'true'.
Does not change any old functionality.
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.
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/doc/src/os.xml | 11 | ||||
-rw-r--r-- | lib/kernel/src/os.erl | 8 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml index 5e182de41d..9122267c40 100644 --- a/lib/kernel/doc/src/os.xml +++ b/lib/kernel/doc/src/os.xml @@ -177,6 +177,17 @@ format_utc_timestamp() -> </desc> </func> <func> + <name name="unsetenv" arity="1"/> + <fsummary>Delete an environment variable</fsummary> + <desc> + <p>Deletes the environment variable <c><anno>VarName</anno></c>.</p> + <p>If Unicode filename encoding is in effect (see the <seealso + marker="erts:erl#file_name_encoding">erl manual + page</seealso>), the string (<c><anno>VarName</anno></c>) may + contain characters with codepoints > 255.</p> + </desc> + </func> + <func> <name name="version" arity="0"/> <fsummary>Return the Operating System version</fsummary> <desc> diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index ded03361ee..9415593485 100644 --- a/lib/kernel/src/os.erl +++ b/lib/kernel/src/os.erl @@ -26,7 +26,7 @@ %%% BIFs --export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0]). +-export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0, unsetenv/1]). -spec getenv() -> [string()]. @@ -58,6 +58,12 @@ putenv(_, _) -> timestamp() -> erlang:nif_error(undef). +-spec unsetenv(VarName) -> true when + VarName :: string(). + +unsetenv(_) -> + erlang:nif_error(undef). + %%% End of BIFs -spec type() -> {Osfamily, Osname} when |