Oleksandr Bratashov
Oleksandr Bratashov

Reputation: 908

How to quit after run IO.read(:stdio, :all) in the Elixir iex?

I need test some input data flow, and use 'IO.read', but after entering data i can't exit from this mode, CTRL-Z/X/C/D doesn't help (it terminates the whole iex). So how correct EOF command for this mode? Thanks!

Upvotes: 0

Views: 569

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121010

TL;DR: Use ^G followed by j, i [nn] and c [nn].


In both erl and iex shells you always might ^G to enter a “User switch command” mode. Type h for help there.

iex|1 ▶ IO.read :stdio, :all

^G
User switch command
  --> j
    1* {erlang,apply,[#Fun<Elixir.IEx.CLI.1.96155272>,[]]}
  --> i 1
  --> c 1
{:error, :interrupted}

iex|2 ▶

Sidenote: the correct EOF termination would be ^D in all the terminals. I honestly have no idea why it does not work as expected in erl/iex consoles.

Upvotes: 2

Related Questions