ijverig
How to stop input inside iex
How could I send an EOF/EOT inside an input in iex?
Say inside
iex> IO.read :all
Usually we do it by pressing ctrl+D on other shells, but that’s something else in Erlang.
If there isn’t a way, how could I stop the input in a way that I could access the data already entered?
First Post!
scarfacedeb
You can use Ctrl + G to enter Job control mode, there you can interrupt the running job (e.g. with i 1) and connect to it back.
iex(5)> IO.read :all
1111
User switch command
--> j
1* {erlang,apply,[#Fun<Elixir.IEx.CLI.1.121285560>,[]]}
--> i 1
--> c 1
{:error, :interrupted}
iex(6)>
Most Liked
jstimps
It appears erl and iex both block the user from issuing the EOF signal, which can usually be done with Ctrl+d.
However, if you use elixir then it works!
$ elixir --eval 'IO.write("> "); l = IO.read(:stdio, :line); IO.inspect(l)'
> :eof
At the prompt above, I gave Ctrl+d and it got :eof like expected. However, this doesn’t work in iex; I assume this is on purpose to avoid accidentally terminating the shell input loop.
Hope this helps other future searchers ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









