otp 26 messes up the tty
mbj4668 opened this issue · 0 comments
mbj4668 commented
Describe the bug
Run an escript that prodcues (slow) output, pipe it to less
, and hit q
to quit less. The tty is now in a bad state (e.g., with bash, prev history doesn't work). reset
or stty sane
is needed to fix it.
To Reproduce
Save the script below as test
, make it executable and run test <name of a large text file> | less
in bash. Hit q
. Wait. When you get the bash prompt, try ctrl-p etc.
#!/usr/bin/env escript
%% -*- erlang -*-
main([FName]) ->
{ok, Fd} = file:open(FName, [read]),
loop(Fd),
file:close(Fd).
loop(Fd) ->
case file:read(Fd, 1024) of
{ok, Data} ->
io:put_chars(Data),
timer:sleep(500),
loop(Fd);
_ ->
done
end.
Expected behavior
The tty should not be messed up. Also, it takes several seconds more than in 25 to get the prompt back.
Affected versions
I have tried 26.1.2 and 26.2.5.