Proposal: Adopt password prompt from Hex into Kernel.IO

45 views
Skip to first unread message

Spencer Gilson

unread,
Jul 15, 2020, 1:26:46 AM7/15/20
to elixir-lang-core
 Prompting a user for a secret is not too uncommon, especially when building CLI applications. Due to an issue that has remained unresolved for many years, :io.get_password() does not work when invoked in a Mix task or through escript. This is unfortunate as I would guess that these are the primary environments that users are likely to use that function. I believe that Elixir would benefit from a standard method that can accomplish this functionality both in normal operation and in the environments mentioned above.

Hex currently has an implementation that appears to be stable, and I believe it would suitable to adopt it as a utility method in Kernel.IO. Ideally, the behavior would wrap the Erlang library similar to how other functions in the module do, however, I feel the logic to compensate for the problem in :io would either require matching the error tuple:

{:error, {:request, {:get_password, :unicode}}}

or checking environment conditions to see if the Erlang method is likely to succeed, neither of which seem like a great solution.

If there is any reason that the Hex implemenation is not suitable as a standard in the absence of support from :io, I'm really interested, especially if there are portability issues.

In the mean time, I'll adopt the function into my own project with a reference to Hex :P



José Valim

unread,
Jul 15, 2020, 3:18:36 AM7/15/20
to elixir-l...@googlegroups.com
Unfortunately the solution in Hex has some pitfalls, like it requires to erase the current line, and potentially others. In my opinion it is not general purpose enough to be included in stdlib.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/8724762b-428a-4aca-a4cf-bb9e0bed8e08o%40googlegroups.com.

Spencer Gilson

unread,
Jul 19, 2020, 2:36:58 PM7/19/20
to elixir-lang-core
Hmm. I see what you mean now. Is this simply impossible to accomplish inside the VM without a fix from Erlang?

On Wednesday, July 15, 2020 at 12:18:36 AM UTC-7, José Valim wrote:
Unfortunately the solution in Hex has some pitfalls, like it requires to erase the current line, and potentially others. In my opinion it is not general purpose enough to be included in stdlib.

On Wed, Jul 15, 2020 at 7:26 AM Spencer Gilson <spence...@gmail.com> wrote:
 Prompting a user for a secret is not too uncommon, especially when building CLI applications. Due to an issue that has remained unresolved for many years, :io.get_password() does not work when invoked in a Mix task or through escript. This is unfortunate as I would guess that these are the primary environments that users are likely to use that function. I believe that Elixir would benefit from a standard method that can accomplish this functionality both in normal operation and in the environments mentioned above.

Hex currently has an implementation that appears to be stable, and I believe it would suitable to adopt it as a utility method in Kernel.IO. Ideally, the behavior would wrap the Erlang library similar to how other functions in the module do, however, I feel the logic to compensate for the problem in :io would either require matching the error tuple:

{:error, {:request, {:get_password, :unicode}}}

or checking environment conditions to see if the Erlang method is likely to succeed, neither of which seem like a great solution.

If there is any reason that the Hex implemenation is not suitable as a standard in the absence of support from :io, I'm really interested, especially if there are portability issues.

In the mean time, I'll adopt the function into my own project with a reference to Hex :P



--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.

José Valim

unread,
Jul 19, 2020, 2:52:12 PM7/19/20
to elixir-l...@googlegroups.com
I *think* so, yes.

To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/253b4a26-47dd-4d76-b130-e3147b9660e9o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages