mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Trap SIGINT on jruby by default
This commit is contained in:
parent
ad62ecaf8b
commit
76336c5780
2 changed files with 14 additions and 0 deletions
|
@ -98,6 +98,12 @@ class Pry
|
|||
# @return [Boolean]
|
||||
attr_accessor :disable_auto_reload
|
||||
|
||||
# Determins whether Pry should trap SIGINT and cause it to raise an
|
||||
# Interrupt exception. This is only useful on jruby, MRI does this
|
||||
# for us.
|
||||
# @return [Boolean]
|
||||
attr_accessor :should_trap_interrupts
|
||||
|
||||
# Config option for history.
|
||||
# sub-options include hist.file, hist.load, and hist.save
|
||||
# hist.file is the file to save/load history too, e.g
|
||||
|
|
|
@ -73,6 +73,12 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
# Trap interrupts on jruby, and make them behave like MRI so we can
|
||||
# catch them.
|
||||
def self.load_traps
|
||||
trap('INT'){ raise Interrupt }
|
||||
end
|
||||
|
||||
# Do basic setup for initial session.
|
||||
# Including: loading .pryrc, loading plugins, loading requires, and
|
||||
# loading history.
|
||||
|
@ -87,6 +93,7 @@ class Pry
|
|||
load_plugins if Pry.config.plugins.enabled
|
||||
load_requires if Pry.config.should_load_requires
|
||||
load_history if Pry.config.history.should_load
|
||||
load_traps if Pry.config.should_trap_interrupts
|
||||
|
||||
@initial_session = false
|
||||
end
|
||||
|
@ -202,6 +209,7 @@ class Pry
|
|||
config.system = DEFAULT_SYSTEM
|
||||
config.editor = default_editor_for_platform
|
||||
config.should_load_rc = true
|
||||
config.should_trap_interrupts = defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
||||
config.disable_auto_reload = false
|
||||
config.command_prefix = ""
|
||||
config.auto_indent = true
|
||||
|
|
Loading…
Reference in a new issue