aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorPeter Lemenkov <[email protected]>2014-11-08 15:11:04 +0300
committerPeter Lemenkov <[email protected]>2014-12-15 21:05:05 +0300
commit5cbad390e971ff92a7fb1b71757041ff9edeb81a (patch)
tree5ea8891717e8d41ef64a351973e3a27608de50a2 /lib/kernel/src
parentaf87b1c3d4897840d8247589a88d3611106ecedc (diff)
downloadotp-5cbad390e971ff92a7fb1b71757041ff9edeb81a.tar.gz
otp-5cbad390e971ff92a7fb1b71757041ff9edeb81a.tar.bz2
otp-5cbad390e971ff92a7fb1b71757041ff9edeb81a.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.erl15
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().