Skip to content

Commit

Permalink
Sanitize reset stty state around interruptible block
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Nov 19, 2019
1 parent db286e2 commit b3c74d0
Showing 1 changed file with 15 additions and 1 deletion.
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_sane_stty do
with_repl_like_sigint { 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

0 comments on commit b3c74d0

Please sign in to comment.