Getting a single character from the console without hitting enter in Elixir/Erlang

83 views Asked by At

I upgraded my Elixir app from version 1.8 to 1.15.7. Now my code that enables getting a single character from the console without having to hit enter does not work anymore:

{:ok, Port.open({:spawn, "tty_sl -c -e"}, [:binary, :eof])}

I have Erlang 26.0.2 installed but it seems tty_sl is no longer present. Is there another way to get a single character without hitting enter?

1

There are 1 answers

0
Aleksei Matiushkin On

It’s hard to tell what you are actually trying to achieve, but yes, tty_sl has been removed from OTP 26 in favor of internal shell handling.

What you probably need, would be to spawn a regular tty and then send stty raw -echo command to it right after it’s started.