os:getenv regression

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

os:getenv regression

Richard Bowker
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?

Rich

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: os:getenv regression

Raimo Niskanen-11
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&nbsp; (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1&gt; os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2&gt; os:getenv(&lt;&lt;""&gt;&gt;).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3&gt;&nbsp;</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&nbsp; (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1&gt; os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2&gt; os:getenv(&lt;&lt;""&gt;&gt;).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">** exception error: bad argument</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">&nbsp; &nbsp; &nbsp;in function&nbsp; os:get_env_var/1</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; called as os:get_env_var(&lt;&lt;&gt;&gt;)</FONT></DIV><DIV style=""><FONT face="Arial, sans-se
 rif">&nbsp; &nbsp; &nbsp;in call from os:getenv/1 (os.erl, line 124)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3&gt;&nbsp;</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
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: os:getenv regression

陈梓立
Hi Richard,

This change was introduced by this commit and I think it is by implementation.

Best,
tison.


Raimo Niskanen <[hidden email]> 于2018年9月6日周四 下午9:12写道:
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&nbsp; (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1&gt; os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2&gt; os:getenv(&lt;&lt;""&gt;&gt;).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3&gt;&nbsp;</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&nbsp; (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1&gt; os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2&gt; os:getenv(&lt;&lt;""&gt;&gt;).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">** exception error: bad argument</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">&nbsp; &nbsp; &nbsp;in function&nbsp; os:get_env_var/1</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; called as os:get_env_var(&lt;&lt;&gt;&gt;)</FONT></DIV><DIV style=""><FONT face="Arial, sans-se
 rif">&nbsp; &nbsp; &nbsp;in call from os:getenv/1 (os.erl, line 124)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3&gt;&nbsp;</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
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: os:getenv regression

Raimo Niskanen-11
In reply to this post by Richard Bowker
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
>
> --- [hidden email] wrote:
>
> From: Raimo Niskanen <[hidden email]>
> To: Richard Bowker <[hidden email]>, <[hidden email]>
> 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&nbsp; (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1&gt; os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2&gt; os:getenv(&lt;&lt;""&gt;&gt;).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3&gt;&nbsp;</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&nbsp; (abort with ^G)</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">1&gt; os:getenv("").</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">false</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">2&gt; os:getenv(&lt;&lt;""&gt;&gt;).</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">** exception error: bad argument</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">&nbsp; &nbsp; &nbsp;in function&nbsp; os:get_env_var/1</FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; called as os:get_env_var(&lt;&lt;&gt;&gt;)</FONT></DIV><DIV style=""><FONT face="Arial, sans-
 serif">&nbsp; &nbsp; &nbsp;in call from os:getenv/1 (os.erl, line 12
> /FONT></DIV><DIV style=""><FONT face="Arial, sans-serif">3&gt;&nbsp;</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
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions