-
-
Notifications
You must be signed in to change notification settings - Fork 325
/
irb.rb
50 lines (40 loc) · 937 Bytes
/
irb.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
require "byebug/command"
require "irb"
require "English"
module Byebug
#
# Enter IRB from byebug's prompt
#
class IrbCommand < Command
self.allow_in_post_mortem = true
def self.regexp
/^\s* irb \s*$/x
end
def self.description
<<-DESCRIPTION
irb
#{short_description}
DESCRIPTION
end
def self.short_description
"Starts an IRB session"
end
def execute
return errmsg(pr("base.errors.only_local")) unless processor.interface.instance_of?(LocalInterface)
# @todo IRB tries to parse $ARGV so we must clear it (see #197). Add a
# test case for it so we can remove this comment.
with_clean_argv { IRB.start }
end
private
def with_clean_argv
saved_argv = $ARGV.dup
$ARGV.clear
begin
yield
ensure
$ARGV.concat(saved_argv)
end
end
end
end