commit 0156fcd2ad6037da945ddc153996945c48966fca
Author: Peter Lemenkov <[email protected]>
Date: Mon Dec 1 16:00:04 2014 +0300
Backport useful os:getenv/2 from master
See this GitHub pull request for further details:
* https://github.com/erlang/otp/pull/535
Signed-off-by: Peter Lemenkov <[email protected]>
erlang.spec | 9 ++++-
otp-0011-Introduce-os-getenv-2.patch | 63 ++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/erlang.spec b/erlang.spec
index c1223da..eff8714 100644
--- a/erlang.spec
+++ b/erlang.spec
@@ -10,7 +10,7 @@
Name: erlang
Version: 17.3.4
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: General-purpose programming language and runtime environment
Group: Development/Languages
@@ -71,6 +71,9 @@ Patch9: otp-0009-Expose-NIF-version.patch
# Fedora specific patch
# Split off webtool dependency from tools
Patch10: otp-0010-Split-off-webtool-dependency-from-tools.patch
+# Fedora specific patch
+# Introduce os:getenv/2
+Patch11: otp-0011-Introduce-os-getenv-2.patch
# end of autogenerated patch tag list
BuildRequires: lksctp-tools-devel
@@ -900,6 +903,7 @@ Erlang mode for XEmacs (source lisp files).
%patch8 -p1 -b .Install_internal_hrl_files_when_necessary
%patch9 -p1 -b .Expose_NIF_version
%patch10 -p1 -b .Split_off_webtool_dependency_from_tools
+%patch11 -p1 -b .Introduce_os_getenv_2
# end of autogenerated prep patch list
# FIXME we should come up with a better solution
@@ -2220,6 +2224,9 @@ useradd -r -g epmd -d /tmp -s /sbin/nologin \
%changelog
+* Mon Dec 01 2014 Peter Lemenkov <[email protected]> - 17.3.4-2
+- Backport useful os:getenv/2 from master (see
https://github.com/erlang/otp/pull/535 )
+
* Sat Nov 08 2014 Peter Lemenkov <[email protected]> - 17.3.4-1
- Ver. 17.3.4 (API/ABI compatible release)
- Relax an erlang-tools dependency on erlang-webtool down to Suggests
diff --git a/otp-0011-Introduce-os-getenv-2.patch
b/otp-0011-Introduce-os-getenv-2.patch
new file mode 100644
index 0000000..6c48db2
--- /dev/null
+++ b/otp-0011-Introduce-os-getenv-2.patch
@@ -0,0 +1,63 @@
+From: Peter Lemenkov <[email protected]>
+Date: Sat, 8 Nov 2014 15:11:04 +0300
+Subject: [PATCH] Introduce os:getenv/2
+
+Signed-off-by: Peter Lemenkov <[email protected]>
+
+diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml
+index 2b57e75..8b85f24 100644
+--- a/lib/kernel/doc/src/os.xml
++++ b/lib/kernel/doc/src/os.xml
+@@ -100,6 +100,19 @@ DirOut = os:cmd("dir"), % on Win32 platform</code>
+ </desc>
+ </func>
+ <func>
++ <name name="getenv" arity="2"/>
++ <fsummary>Get the value of an environment variable</fsummary>
++ <desc>
++ <p>Returns the <c><anno>Value</anno></c> of the environment variable
++ <c><anno>VarName</anno></c>, or <c>DefaultValue</c> if the
environment variable
++ is undefined.</p>
++ <p>If Unicode file name encoding is in effect (see the <seealso
++ marker="erts:erl#file_name_encoding">erl manual
++ page</seealso>), the strings (both <c><anno>VarName</anno></c> and
++ <c><anno>Value</anno></c>) may contain characters with codepoints >
255.</p>
++ </desc>
++ </func>
++ <func>
+ <name name="getpid" arity="0"/>
+ <fsummary>Return the process identifier of the emulator
process</fsummary>
+ <desc>
+diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
+index 187fd00..8aaf13b 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().
+
_______________________________________________
erlang mailing list
[email protected]
https://lists.fedoraproject.org/mailman/listinfo/erlang