[erlang-questions] os:getenv regression
Raimo Niskanen
raimo+erlang-questions@REDACTED
Fri Sep 7 08:54:11 CEST 2018
On Thu, Sep 06, 2018 at 08:14:19AM -0700, Richard Bowker wrote:
> I always forget to change the mode! :)
You might have a dual mode that would allow text only clients to show a
text only version of the mail. :-)
>
> In OTP-20 os:getenv accepted either strings or binaries:
>
> Erlang/OTP 20 [erts-9.3.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:10] [hipe] [kernel-poll:false]
>
> Eshell V9.3.3 (abort with ^G)
> 1> os:getenv("").
> false
> 2> os:getenv(<<"">>).
> false
> 3>
>
>
> however in OTP-21
>
> Erlang/OTP 21 [erts-10.0.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]
>
> Eshell V10.0.5 (abort with ^G)
> 1> os:getenv("").
> false
> 2> os:getenv(<<"">>).
> ** exception error: bad argument
> in function os:get_env_var/1
> called as os:get_env_var(<<>>)
> in call from os:getenv/1 (os.erl, line 124)
> 3>
>
>
> Was this change deliberate?
os:getenv/1 has since forever been documented to accept a string() as its
argument. So it seems that during a rewrite to OTP-21.0 the undocumented
feature to also accept a binary or maybe even an iolist was removed.
That feature was not documented, so therefore the change is according to
some definition not a regression since the behaviour was never supported.
:-)
Note that the function is now documented to accept nonempty_string(),
so therefore the behaviour to return false for the argument "" is now
not supported. According to the new definition the function is allowed
to crash for the argument "".
I do not know if that was an intended change or not...
Best Regards
/ Raimo Niskanen
>
> Rich
>
> --- raimo+erlang-questions@REDACTED wrote:
>
> From: Raimo Niskanen <raimo+erlang-questions@REDACTED>
> To: Richard Bowker <erlang@REDACTED>, <erlang-questions@REDACTED>
> Subject: Re: [erlang-questions] os:getenv regression
> Date: Thu, 6 Sep 2018 15:12:23 +0200
>
> My mail client does not like your mail client.
> I think the list policies say something about not HTML-only posts...
>
> On Thu, Sep 06, 2018 at 05:20:10AM -0700, Richard Bowker wrote:
> > <DIV style="font-family:Arial, sans-serif; font-size:10pt;"><FONT size="2" style=""><FONT face="Arial, sans-serif">In OTP-20 os:getenv accepted either strings or binaries:</FONT><BR><BR><DIV style=""><FONT face="Arial, sans-serif">Erlang/OTP 20 [erts-9.3.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:10] [hipe] [kernel-poll:false]</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif"><BR></FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">Eshell V9.3.3 (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1> os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2> os:getenv(<<"">>).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3> </FONT></DIV><DIV style="font-family: Arial, sans-serif;"><BR></DIV><DIV style="font-family: Arial, sans-serif;"><BR></DIV><DIV style=""><FONT face="Arial, sans-serif">however in OTP-21</FONT><BR><BR><DIV style=""><FONT face="Arial, sans-serif">Erlang/OTP 21 [erts-10.0.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif"><BR></FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">Eshell V10.0.5 (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1> os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2> os:getenv(<<"">>).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">** exception error: bad argument</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif"> in function os:get_env_var/1</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif"> called as os:get_env_var(<<>>)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif"> in call from os:getenv/1 (os.erl, line 12
> /FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3> </FONT></DIV><DIV style="font-family: Arial, sans-serif;"><BR><BR>Was this change deliberate?</DIV><DIV style="font-family: Arial, sans-serif;"><BR></DIV><DIV style="font-family: Arial, sans-serif;">Rich</DIV></DIV></FONT></DIV>
>
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>
>
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list