-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Readline is (probably) not restoring terminal settings after reading line #3181
Comments
So here's the
Unless my eyes deceive me, Using -a output, here's before and after for lflag:
So icanon is not being restored. icanon sets "canonical mode" according to the manpage:
I'm not sure what the equivalent is in jline (the library we use for readline) but I will investigate. |
Well, that didn't take long. I found this little nugget in the UnixTerminal class from jline:
So it looks like it disables canonical input when we start using it and never turns it back on. This is a bug in jline...I suggest you file it there (https://github.com/jline/jline2), reference this bug, and I will help you work with them to come up with a fix. We'll leave this open meanwhile. |
FWIW your workaround of restoring with stty is probably good enough for now; it appears that jline just uses stty for terminal modes anyway. |
Hi @headius With the fragment of code you have posted I was able to walk a little at the code and see that "indeed" for "unix" terminals they just use stty external program (as I was doing). So I will stay with this workaround. Thank you very much! I have opened the issue on JLine as you told me. I don't know what your policies for issues like this, that are pending because of external issues. Do you just close the issue? Or you let it open until the external dependency gets fixed? I'm good with both, so feel free. |
We would leave it open. Unfortunately, it doesn't appear that jline2 is very active right now :-\ |
Hi @headius, Just commenting here to let you know that we have merged the PR JEG2/highline#149 We have opted to call Readline.readline inside a block that saves and restores the stty state afterwards. I think you have commented on using rb-readline in place of the builtin readline (I'm not sure). I'll try to open an issue on rb-readline for that. Rawline, as the other option, is looking a little unmaintained, as far as I could see. So, we still don't have the silver bullet to make things work at different platforms. |
I have reported 2 issues on rb-readline |
See jline/jline2#210 (comment). |
on JRuby runtime tear-down we never did this but updated jline sets **-icrnl** and that causes issues: jruby/jruby#5387 previous jline wasn't setting icrnl but still unresolved on restoring see jruby/jruby#3181
since the previous attempt (on runtime tear-down) does not always work towards getting updates back: jruby/jruby#5387 actually also resolves: jruby/jruby#3181
since the previous attempt (on runtime tear-down) does not always work towards getting updates back: jruby/jruby#5387 actually also resolves: jruby/jruby#3181
here should be some progress here (for JRuby >= 9.2.4.0) with jruby-readline 1.3.7 restoring should be in place |
Move another Readline issue into 9.3.0.0, since we intend to ship the |
Interestingly this still seems to be a problem with reline instead of readline, even though that library should have fixed most issues like this.
We will want to investigate this in 9.4.1. I suspect the current behavior is likely an undiscovered bug in the io-console library, but forcing CRuby to use reline and our version of io-console does not reproduce the issue. 🤔 |
Punted to 9.4.2, just didn't get around to it. Someone else could possibly confirm what is changing in the TTY with reline, so I have a place to start. I doubt we will ever see a fix to jline so the 9.3 line probably will have to live with this bug for a while. |
Ah, actually we need to confirm if we are properly shutting down jline as mentioned in jline/jline2#210. If the shutdown logic suggested there works properly, then the jruby-readline library just needs to add a shutdown hook to call it. |
I'm going to kill this one. The path forward is using reline with minimal native calls in io/console to handle most of the terminal tweaking. jline is largely dead as far as maintenance and we don't ship it anymore. |
After a Readline.readline it's not possible to enter inputs using simple #gets
The code above runs ok on MRI 2.2.2 and Rubinius 2.2.6
I suspect that it could be related to not restoring terminal settings after reading line.
As with this code bellow, everything works fine.
I would really appreciate any feedback. Thanks in advance!
The text was updated successfully, but these errors were encountered: