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

Reset stty state around interruptible block #604

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/byebug/interfaces/local_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def initialize
# @param prompt Prompt to be displayed.
#
def readline(prompt)
with_repl_like_sigint { Readline.readline(prompt) || EOF_ALIAS }
with_repl_like_sigint do
with_sane_stty { Readline.readline(prompt) || EOF_ALIAS }
end
end

#
Expand All @@ -40,5 +42,17 @@ def with_repl_like_sigint
ensure
trap("INT", orig_handler)
end

#
# Saves the initial terminal settings and restores them in the end, since
# reline does not seem to properly reset them.
#
def with_sane_stty
stty_save = `stty -g`.chomp

yield
ensure
`stty #{stty_save}`
end
end
end