diff options
author | Peter Lemenkov <[email protected]> | 2014-11-08 15:11:04 +0300 |
---|---|---|
committer | Marcus Arendt <[email protected]> | 2014-11-26 15:40:53 +0100 |
commit | ae13f4759fd47c0db36c8a3bd9759e01d709ee02 (patch) | |
tree | f5147f29ee37648f885dd7a2839302dfd7edea18 /lib/kernel/src | |
parent | a02a9fdccaf0ba94503bc10b81a55a6aeec8d760 (diff) | |
download | otp-ae13f4759fd47c0db36c8a3bd9759e01d709ee02.tar.gz otp-ae13f4759fd47c0db36c8a3bd9759e01d709ee02.tar.bz2 otp-ae13f4759fd47c0db36c8a3bd9759e01d709ee02.zip |
Introduce os:getenv/2
Signed-off-by: Peter Lemenkov <[email protected]>
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/os.erl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index 187fd0001b..8aaf13b3fd 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, unsetenv/1]). +-export([getenv/0, getenv/1, getenv/2, getpid/0, putenv/2, timestamp/0, unsetenv/1]). -spec getenv() -> [string()]. @@ -39,6 +39,19 @@ getenv() -> erlang:nif_error(undef). getenv(_) -> erlang:nif_error(undef). +-spec getenv(VarName, DefaultValue) -> Value when + VarName :: string(), + DefaultValue :: string(), + Value :: string(). + +getenv(VarName, DefaultValue) -> + case os:getenv(VarName) of + false -> + DefaultValue; + Value -> + Value + end. + -spec getpid() -> Value when Value :: string(). |