Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input is lost with erl -noshell -eval "shell:start_interactive()." #7650

Closed
josevalim opened this issue Sep 13, 2023 · 4 comments
Closed

Input is lost with erl -noshell -eval "shell:start_interactive()." #7650

josevalim opened this issue Sep 13, 2023 · 4 comments
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@josevalim
Copy link
Contributor

When the shell is started interactively (because it has to be started by Elixir, rebar3, or something else), any previous input is lost (i.e. not read as part of the shell). It can be reproduced with these two scripts (save them to a file, chmod +x FILE, and run them):

Working script

#!/usr/bin/expect
spawn erl
send "\"Hello World\".\n"
interact

The script above will send "Hello world" to the shell.

Non-working script

#!/usr/bin/expect
spawn erl -noshell -eval "shell:start_interactive()."
send "\"Hello World\".\n"
interact

The script above will not send "Hello world" to the shell.

Expected behavior

Perhaps it makes sense to read any buffered input when starting the shell? I am also fine if this is expected somehow, but I thought I would report.

Affected versions

Erlang/OTP 26. Note this works fine if I use -user but I think starting the shell interactively is a better experience. :)

Thank you.

@josevalim josevalim added the bug Issue is reported as a bug label Sep 13, 2023
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Sep 13, 2023
@garazdawi
Copy link
Contributor

You need to use -noinput in such scenarios. The -noshell option is for when you want to start a system without a shell and then use io:read or something like that to get the data.

@josevalim
Copy link
Contributor Author

I am not sure if that's always possible. I assume, for example, rebar3 starts with -noshell because a task may need to read some input, but particular commands such as rebar3 shell may start the shell.

Feel free to close this anyway, if it is not worth it though. I just need to know the plan so I can document it. :)

@garazdawi
Copy link
Contributor

If you need to read input then you can do shell:start_interactive(noshell) after the system was started with -noinput.

@josevalim
Copy link
Contributor Author

Got it, thank you!

@josevalim josevalim closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants