irb 1.14.0 → 1.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -2
- data/lib/irb/command/base.rb +10 -8
- data/lib/irb/command/debug.rb +8 -6
- data/lib/irb/command/help.rb +1 -1
- data/lib/irb/command/internal_helpers.rb +1 -1
- data/lib/irb/command/ls.rb +23 -11
- data/lib/irb/completion.rb +12 -5
- data/lib/irb/context.rb +60 -17
- data/lib/irb/debug/ui.rb +2 -4
- data/lib/irb/debug.rb +6 -10
- data/lib/irb/default_commands.rb +15 -7
- data/lib/irb/easter-egg.rb +10 -6
- data/lib/irb/history.rb +80 -55
- data/lib/irb/init.rb +1 -1
- data/lib/irb/input-method.rb +19 -18
- data/lib/irb/inspector.rb +31 -30
- data/lib/irb/lc/ja/help-message +4 -4
- data/lib/irb/nesting_parser.rb +196 -194
- data/lib/irb/pager.rb +10 -1
- data/lib/irb/ruby-lex.rb +84 -82
- data/lib/irb/ruby_logo.aa +75 -37
- data/lib/irb/source_finder.rb +3 -4
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +13 -31
- data/lib/irb.rb +44 -67
- data/man/irb.1 +35 -2
- metadata +2 -2
data/lib/irb/ruby_logo.aa
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
TYPE:
|
1
|
+
TYPE: ASCII_LARGE
|
2
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
|
-
|
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
39
|
TYPE: ASCII
|
40
40
|
,,,;;;;''''';;;'';,
|
41
41
|
,,;'' ';;,;;; ',
|
@@ -57,6 +57,44 @@ TYPE: ASCII
|
|
57
57
|
;;; '; ;' ';,,'' ';,;;
|
58
58
|
'; ';,; ,,;''''''''';;;;;;,,;;;
|
59
59
|
';,,;;,,;;;;;;;;;;''''''''''''''
|
60
|
+
TYPE: UNICODE_LARGE
|
61
|
+
|
62
|
+
⣀⣤⣴⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣤⣄⡀
|
63
|
+
⢀⣀⣤⣴⣾⣿⣿⣿⠿⣿⣿⣿⣿⣦⣀ ⢀⣤⣶⣿⠿⠛⠁⠈⠉⠙⠻⢿⣷⣦⡀
|
64
|
+
⢀⣠⣴⣾⡿⠿⠛⠉⠉ ⠈⠙⢿⣿⣷⣤⡀ ⣠⣴⣾⡿⠟⠉ ⠉⠻⣿⣦
|
65
|
+
⢀⣤⣶⣿⠟⠋⠁ ⢿⣿⣿⣿⣿⣿⣿⣧⣤⣤⣤⣀⣀⣀⡀ ⠘⢿⣷⡀
|
66
|
+
⢀⣠⣾⡿⠟⠉ ⢸⣿⣿⣿⠟⢿⣿⣯⡙⠛⠛⠛⠿⠿⠿⢿⣿⣿⣶⣶⣶⣦⣤⣬⣿⣧
|
67
|
+
⣠⣴⣿⠟⠋ ⢸⣿⣿⡿ ⠈⠻⣿⣶⣄ ⠉⠉⠉⠙⠛⢻⣿⡆
|
68
|
+
⣠⣾⡿⠛⠁ ⣼⣿⣿⠃ ⠈⠙⢿⣷⣤⡀ ⠈⣿⡇
|
69
|
+
⣠⣾⡿⠋ ⢠⣿⣿⡏ ⠙⠻⣿⣦⣀ ⣿⡇
|
70
|
+
⣠⣾⡿⠋ ⢀⣿⣿⣿ ⠈⠛⢿⣷⣄⡀ ⢠⣿⡇
|
71
|
+
⢀⣾⡿⠋ ⢀⣾⣿⣿⠇ ⠙⠻⣿⣦⣀ ⢸⣿⡇
|
72
|
+
⢀⣴⣿⠟⠁ ⢀⣾⣿⣿⡟ ⠈⠻⢿⣷⣄ ⣾⣿⠇
|
73
|
+
⢠⣾⡿⠃ ⣠⣿⣿⣿⣿⠃ ⣀⣀⣀⣀⣀⣀⣀⣀⣤⣤⣤⣤⣽⣿⣿⣿⣿
|
74
|
+
⣰⣿⠟ ⣴⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠛⠛⠛⠛⠛⠛⠛⠛⣿⣿⣿
|
75
|
+
⣼⣿⠏ ⢠⣾⣿⣿⣿⡿⣿⣿⢿⣷⣦⣄ ⣼⣿⣿⣿
|
76
|
+
⣼⣿⠃ ⢀⣴⣿⣿⣿⠟⠋ ⢸⣿⡆⠈⠛⠿⣿⣦⣄⡀ ⣰⣿⣿⣿⡇
|
77
|
+
⢀⣾⣿⠃ ⢀⣴⣿⣿⣿⠟⠁ ⣿⣷ ⠈⠙⠻⣿⣶⣄⡀ ⣰⣿⠟⣿⣿⡇
|
78
|
+
⢀⣾⣿⠇ ⢀⣴⣿⣿⣿⠟⠁ ⢸⣿⡆ ⠙⠻⢿⣷⣤⣀ ⣰⣿⠏⢠⣿⣿⡇
|
79
|
+
⢠⣿⣿⡟ ⢀⣴⣿⣿⡿⠛⠁ ⣿⣷ ⠉⠻⢿⣷⣦⣀ ⣴⣿⠏ ⢸⣿⣿⠃
|
80
|
+
⣿⣿⣿⡇ ⣠⣴⣿⣿⡿⠋ ⢸⣿⡆ ⠈⠛⢿⣿⣿⠃ ⢸⣿⣿
|
81
|
+
⢠⣿⣿⣿ ⢀⣴⣾⣿⣿⡿⠋ ⠈⣿⣧ ⢠⣾⣿⣿ ⢸⣿⣿
|
82
|
+
⢸⣿⣿⣿⡇ ⣀⣴⣾⣿⣿⣿⡿⠋ ⢹⣿⡆ ⣴⣿⠟⢹⣿⡀ ⢸⣿⡿
|
83
|
+
⢸⣿⡟⣿⣿⣄ ⣀⣤⣶⣿⣿⣿⣿⣿⡟⠉ ⠈⣿⣷ ⢠⣾⡿⠋ ⢸⣿⡇ ⣼⣿⡇
|
84
|
+
⢸⣿⡇⢹⣿⣿⣷⣦⣤⣤⣤⣤⣤⣴⣶⣾⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣷⣶⣤⣤⣀⡀ ⢹⣿⡆ ⢀⣴⣿⠟ ⣿⣧ ⣿⣿⡇
|
85
|
+
⢸⣿⠃ ⢿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠛⠛⠉⠉⠁ ⢰⣿⠟⣿⣷⡀⠉⠙⠛⠿⢿⣿⣶⣦⣤⣀⡀ ⠈⣿⣷ ⣠⣿⡿⠁ ⢿⣿ ⣿⣿⡇
|
86
|
+
⢸⣿ ⢀⣾⣿⣿⠋⠉⠁ ⢀⣿⡿ ⠘⣿⣷⡀ ⠉⠙⠛⠿⠿⣿⣶⣦⣤⣄⣀ ⢹⣿⡄ ⣠⣾⡿⠋ ⢸⣿⡆ ⣿⣿
|
87
|
+
⣸⣿⢀⣾⣿⣿⣿⣆ ⣸⣿⠃ ⠘⢿⣷⡀ ⠈⠉⠛⠻⠿⣿⣷⣶⣤⣌⣿⣷⣾⡿⠋ ⠘⣿⡇ ⣿⣿
|
88
|
+
⣿⣿⣾⡿⣿⡿⠹⣿⡆ ⢠⣿⡏ ⠈⢿⣷⡀ ⠈⠉⠙⣻⣿⣿⣿⣀ ⣿⣷⢰⣿⣿
|
89
|
+
⣿⣿⡿⢁⣿⡇ ⢻⣿⡄ ⣾⣿ ⠈⢿⣷⡀ ⢀⣤⣾⡿⠋⠈⠻⢿⣷⣄ ⢻⣿⢸⣿⡟
|
90
|
+
⣿⣿⠁⢸⣿⡇ ⢻⣿⡄ ⢸⣿⠇ ⠈⢿⣷⡀ ⣀⣴⣿⠟⠋ ⠙⢿⣷⣤⡀ ⢸⣿⣿⣿⡇
|
91
|
+
⣿⣿ ⢸⣿⠁ ⠈⢿⣷⡀ ⢀⣿⡟ ⠈⢿⣷⡀ ⢀⣤⣾⡿⠛⠁ ⠙⠻⣿⣦⡀ ⠈⣿⣿⣿⡇
|
92
|
+
⢸⣿⡄⣿⣿ ⠈⣿⣷⡀ ⣼⣿⠃ ⠈⢿⣷⡀ ⢀⣠⣶⣿⠟⠋ ⠈⠻⣿⣦⣄ ⣿⣿⣿⠇
|
93
|
+
⠈⣿⣷⣿⡿ ⠘⣿⣧ ⢠⣿⡏ ⠈⢿⣷⣄⣤⣶⣿⠟⠋ ⠈⠛⢿⣷⣄ ⢸⣿⣿
|
94
|
+
⠘⣿⣿⡇ ⠘⣿⣧ ⣾⣿ ⢀⣠⣼⣿⣿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣶⣤⣤⣤⣤⣤⣤⣀⣀⣀⣀⣀⣀⡀ ⠙⢿⣷⣼⣿⣿
|
95
|
+
⠈⠻⣿⣦⡀ ⠹⣿⣆⢸⣿⠇ ⣀⣠⣴⣾⡿⠟⠋⠁ ⠉⠉⠉⠉⠉⠉⠛⠛⣛⣛⣛⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿
|
96
|
+
⠈⠻⢿⣷⣦⣄⣀⡀ ⢹⣿⣿⡟ ⢀⣀⣀⣤⣤⣶⣾⣿⣿⣿⣯⣥⣤⣤⣤⣤⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠟⠛⠛⠛⠛⠛⠛⠛⠉⠉⠉⠉⠉⠉
|
97
|
+
⠉⠙⠛⠿⠿⠿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠉
|
60
98
|
TYPE: UNICODE
|
61
99
|
⣀⣤⣴⣾⣿⣿⣿⡛⠛⠛⠛⠛⣻⣿⠿⠛⠛⠶⣤⡀
|
62
100
|
⣀⣴⠾⠛⠉⠁ ⠙⣿⣶⣤⣶⣟⣉ ⠈⠻⣦
|
data/lib/irb/source_finder.rb
CHANGED
@@ -100,7 +100,7 @@ module IRB
|
|
100
100
|
Source.new(file, line)
|
101
101
|
elsif method
|
102
102
|
# Method defined with eval, probably in IRB session
|
103
|
-
source = RubyVM::
|
103
|
+
source = RubyVM::InstructionSequence.of(method)&.script_lines&.join rescue nil
|
104
104
|
Source.new(file, line, source)
|
105
105
|
end
|
106
106
|
rescue EvaluationError
|
@@ -125,9 +125,8 @@ module IRB
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def eval_receiver_or_owner(code)
|
128
|
-
|
129
|
-
|
130
|
-
rescue NameError
|
128
|
+
@irb_context.workspace.binding.eval(code)
|
129
|
+
rescue Exception
|
131
130
|
raise EvaluationError
|
132
131
|
end
|
133
132
|
|
data/lib/irb/version.rb
CHANGED
data/lib/irb/workspace.rb
CHANGED
@@ -4,8 +4,6 @@
|
|
4
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
5
|
#
|
6
6
|
|
7
|
-
require "delegate"
|
8
|
-
|
9
7
|
require_relative "helper_method"
|
10
8
|
|
11
9
|
IRB::TOPLEVEL_BINDING = binding
|
@@ -16,7 +14,7 @@ module IRB # :nodoc:
|
|
16
14
|
# set self to main if specified, otherwise
|
17
15
|
# inherit main from TOPLEVEL_BINDING.
|
18
16
|
def initialize(*main)
|
19
|
-
if main[0]
|
17
|
+
if Binding === main[0]
|
20
18
|
@binding = main.shift
|
21
19
|
elsif IRB.conf[:SINGLE_IRB]
|
22
20
|
@binding = TOPLEVEL_BINDING
|
@@ -70,37 +68,16 @@ EOF
|
|
70
68
|
unless main.empty?
|
71
69
|
case @main
|
72
70
|
when Module
|
73
|
-
@binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
71
|
+
@binding = eval("::IRB.conf[:__MAIN__].module_eval('::Kernel.binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
74
72
|
else
|
75
73
|
begin
|
76
|
-
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
74
|
+
@binding = eval("::IRB.conf[:__MAIN__].instance_eval('::Kernel.binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
77
75
|
rescue TypeError
|
78
76
|
fail CantChangeBinding, @main.inspect
|
79
77
|
end
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
|
-
case @main
|
84
|
-
when Object
|
85
|
-
use_delegator = @main.frozen?
|
86
|
-
else
|
87
|
-
use_delegator = true
|
88
|
-
end
|
89
|
-
|
90
|
-
if use_delegator
|
91
|
-
@main = SimpleDelegator.new(@main)
|
92
|
-
IRB.conf[:__MAIN__] = @main
|
93
|
-
@main.singleton_class.class_eval do
|
94
|
-
private
|
95
|
-
define_method(:binding, Kernel.instance_method(:binding))
|
96
|
-
define_method(:local_variables, Kernel.instance_method(:local_variables))
|
97
|
-
# Define empty method to avoid delegator warning, will be overridden.
|
98
|
-
define_method(:exit) {|*a, &b| }
|
99
|
-
define_method(:exit!) {|*a, &b| }
|
100
|
-
end
|
101
|
-
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, *@binding.source_location)
|
102
|
-
end
|
103
|
-
|
104
81
|
@binding.local_variable_set(:_, nil)
|
105
82
|
end
|
106
83
|
|
@@ -111,6 +88,9 @@ EOF
|
|
111
88
|
attr_reader :main
|
112
89
|
|
113
90
|
def load_helper_methods_to_main
|
91
|
+
# Do not load helper methods to frozen objects and BasicObject
|
92
|
+
return unless Object === @main && !@main.frozen?
|
93
|
+
|
114
94
|
ancestors = class<<main;ancestors;end
|
115
95
|
main.extend ExtendCommandBundle if !ancestors.include?(ExtendCommandBundle)
|
116
96
|
main.extend HelpersContainer if !ancestors.include?(HelpersContainer)
|
@@ -176,11 +156,13 @@ EOF
|
|
176
156
|
end
|
177
157
|
|
178
158
|
module HelpersContainer
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
159
|
+
class << self
|
160
|
+
def install_helper_methods
|
161
|
+
HelperMethod.helper_methods.each do |name, helper_method_class|
|
162
|
+
define_method name do |*args, **opts, &block|
|
163
|
+
helper_method_class.instance.execute(*args, **opts, &block)
|
164
|
+
end unless method_defined?(name)
|
165
|
+
end
|
184
166
|
end
|
185
167
|
end
|
186
168
|
|
data/lib/irb.rb
CHANGED
@@ -14,6 +14,7 @@ require_relative "irb/default_commands"
|
|
14
14
|
|
15
15
|
require_relative "irb/ruby-lex"
|
16
16
|
require_relative "irb/statement"
|
17
|
+
require_relative "irb/history"
|
17
18
|
require_relative "irb/input-method"
|
18
19
|
require_relative "irb/locale"
|
19
20
|
require_relative "irb/color"
|
@@ -220,11 +221,11 @@ require_relative "irb/pager"
|
|
220
221
|
# *new_filepath*, which becomes the history file for the session.
|
221
222
|
#
|
222
223
|
# You can change the number of commands saved by adding to your configuration
|
223
|
-
# file: `IRB.conf[:SAVE_HISTORY] = *n*`,
|
224
|
+
# file: `IRB.conf[:SAVE_HISTORY] = *n*`, where *n* is one of:
|
224
225
|
#
|
225
|
-
# * Positive integer: the number of commands to be saved
|
226
|
-
# *
|
227
|
-
# * `nil`: no commands are to be saved
|
226
|
+
# * Positive integer: the number of commands to be saved.
|
227
|
+
# * Negative integer: all commands are to be saved.
|
228
|
+
# * Zero or `nil`: no commands are to be saved.
|
228
229
|
#
|
229
230
|
#
|
230
231
|
# During the session, you can use methods `conf.save_history` or
|
@@ -880,40 +881,42 @@ module IRB
|
|
880
881
|
# An exception raised by IRB.irb_abort
|
881
882
|
class Abort < Exception;end
|
882
883
|
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
884
|
+
class << self
|
885
|
+
# The current IRB::Context of the session, see IRB.conf
|
886
|
+
#
|
887
|
+
# irb
|
888
|
+
# irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
|
889
|
+
# foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"
|
890
|
+
def CurrentContext # :nodoc:
|
891
|
+
conf[:MAIN_CONTEXT]
|
892
|
+
end
|
891
893
|
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
894
|
+
# Initializes IRB and creates a new Irb.irb object at the `TOPLEVEL_BINDING`
|
895
|
+
def start(ap_path = nil)
|
896
|
+
STDOUT.sync = true
|
897
|
+
$0 = File::basename(ap_path, ".rb") if ap_path
|
896
898
|
|
897
|
-
|
899
|
+
setup(ap_path)
|
898
900
|
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
901
|
+
if @CONF[:SCRIPT]
|
902
|
+
irb = Irb.new(nil, @CONF[:SCRIPT])
|
903
|
+
else
|
904
|
+
irb = Irb.new
|
905
|
+
end
|
906
|
+
irb.run(@CONF)
|
903
907
|
end
|
904
|
-
irb.run(@CONF)
|
905
|
-
end
|
906
908
|
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
909
|
+
# Quits irb
|
910
|
+
def irb_exit(*) # :nodoc:
|
911
|
+
throw :IRB_EXIT, false
|
912
|
+
end
|
911
913
|
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
914
|
+
# Aborts then interrupts irb.
|
915
|
+
#
|
916
|
+
# Will raise an Abort exception, or the given `exception`.
|
917
|
+
def irb_abort(irb, exception = Abort) # :nodoc:
|
918
|
+
irb.context.thread.raise exception, "abort then interrupt!"
|
919
|
+
end
|
917
920
|
end
|
918
921
|
|
919
922
|
class Irb
|
@@ -970,7 +973,7 @@ module IRB
|
|
970
973
|
# debugger.
|
971
974
|
input = nil
|
972
975
|
forced_exit = catch(:IRB_EXIT) do
|
973
|
-
if
|
976
|
+
if History.save_history? && context.io.support_history_saving?
|
974
977
|
# Previous IRB session's history has been saved when `Irb#run` is exited We need
|
975
978
|
# to make sure the saved history is not saved again by resetting the counter
|
976
979
|
context.io.reset_history_counter
|
@@ -1001,9 +1004,10 @@ module IRB
|
|
1001
1004
|
prev_context = conf[:MAIN_CONTEXT]
|
1002
1005
|
conf[:MAIN_CONTEXT] = context
|
1003
1006
|
|
1004
|
-
|
1007
|
+
load_history = !in_nested_session && context.io.support_history_saving?
|
1008
|
+
save_history = load_history && History.save_history?
|
1005
1009
|
|
1006
|
-
if
|
1010
|
+
if load_history
|
1007
1011
|
context.io.load_history
|
1008
1012
|
end
|
1009
1013
|
|
@@ -1128,8 +1132,8 @@ module IRB
|
|
1128
1132
|
return Statement::EmptyInput.new
|
1129
1133
|
end
|
1130
1134
|
|
1131
|
-
code.force_encoding(@context.io.encoding)
|
1132
|
-
if (command, arg = parse_command(code))
|
1135
|
+
code = code.dup.force_encoding(@context.io.encoding)
|
1136
|
+
if (command, arg = @context.parse_command(code))
|
1133
1137
|
command_class = Command.load_command(command)
|
1134
1138
|
Statement::Command.new(code, command_class, arg)
|
1135
1139
|
else
|
@@ -1138,35 +1142,8 @@ module IRB
|
|
1138
1142
|
end
|
1139
1143
|
end
|
1140
1144
|
|
1141
|
-
ASSIGN_OPERATORS_REGEXP = Regexp.union(%w[= += -= *= /= %= **= &= |= &&= ||= ^= <<= >>=])
|
1142
|
-
|
1143
|
-
def parse_command(code)
|
1144
|
-
command_name, arg = code.strip.split(/\s+/, 2)
|
1145
|
-
return unless code.lines.size == 1 && command_name
|
1146
|
-
|
1147
|
-
arg ||= ''
|
1148
|
-
command = command_name.to_sym
|
1149
|
-
# Command aliases are always command. example: $, @
|
1150
|
-
if (alias_name = @context.command_aliases[command])
|
1151
|
-
return [alias_name, arg]
|
1152
|
-
end
|
1153
|
-
|
1154
|
-
# Assignment-like expression is not a command
|
1155
|
-
return if arg.start_with?(ASSIGN_OPERATORS_REGEXP) && !arg.start_with?(/==|=~/)
|
1156
|
-
|
1157
|
-
# Local variable have precedence over command
|
1158
|
-
return if @context.local_variables.include?(command)
|
1159
|
-
|
1160
|
-
# Check visibility
|
1161
|
-
public_method = !!Kernel.instance_method(:public_method).bind_call(@context.main, command) rescue false
|
1162
|
-
private_method = !public_method && !!Kernel.instance_method(:method).bind_call(@context.main, command) rescue false
|
1163
|
-
if Command.execute_as_command?(command, public_method: public_method, private_method: private_method)
|
1164
|
-
[command, arg]
|
1165
|
-
end
|
1166
|
-
end
|
1167
|
-
|
1168
1145
|
def command?(code)
|
1169
|
-
|
1146
|
+
!!@context.parse_command(code)
|
1170
1147
|
end
|
1171
1148
|
|
1172
1149
|
def configure_io
|
@@ -1492,10 +1469,10 @@ module IRB
|
|
1492
1469
|
when "N"
|
1493
1470
|
@context.irb_name
|
1494
1471
|
when "m"
|
1495
|
-
main_str = @context.
|
1472
|
+
main_str = @context.safe_method_call_on_main(:to_s) rescue "!#{$!.class}"
|
1496
1473
|
truncate_prompt_main(main_str)
|
1497
1474
|
when "M"
|
1498
|
-
main_str = @context.
|
1475
|
+
main_str = @context.safe_method_call_on_main(:inspect) rescue "!#{$!.class}"
|
1499
1476
|
truncate_prompt_main(main_str)
|
1500
1477
|
when "l"
|
1501
1478
|
ltype
|
data/man/irb.1
CHANGED
@@ -180,7 +180,7 @@ The default value is 16.
|
|
180
180
|
.El
|
181
181
|
.Pp
|
182
182
|
.Sh ENVIRONMENT
|
183
|
-
.Bl -tag -compact -width "
|
183
|
+
.Bl -tag -compact -width "IRB_USE_AUTOCOMPLETE"
|
184
184
|
.It Ev IRB_LANG
|
185
185
|
The locale used for
|
186
186
|
.Nm .
|
@@ -190,10 +190,43 @@ The path to the personal initialization file.
|
|
190
190
|
.Pp
|
191
191
|
.It Ev XDG_CONFIG_HOME
|
192
192
|
.Nm
|
193
|
-
respects XDG_CONFIG_HOME. If
|
193
|
+
respects XDG_CONFIG_HOME. If it is set and
|
194
|
+
.Ev IRBRC
|
195
|
+
is unset, load
|
194
196
|
.Pa $XDG_CONFIG_HOME/irb/irbrc
|
195
197
|
as a personal initialization file.
|
196
198
|
.Pp
|
199
|
+
.It Ev RI_PAGER
|
200
|
+
The command specified would be used as a pager.
|
201
|
+
.Pp
|
202
|
+
.It Ev PAGER
|
203
|
+
The command specified would be used as a pager if
|
204
|
+
.Ev RI_PAGER
|
205
|
+
is unset.
|
206
|
+
.Pp
|
207
|
+
.It Ev VISUAL
|
208
|
+
Its value would be used to open files by the edit command.
|
209
|
+
.Pp
|
210
|
+
.It Ev EDITOR
|
211
|
+
Its value would be used to open files by the edit command if
|
212
|
+
.Ev VISUAL
|
213
|
+
is unset.
|
214
|
+
.Pp
|
215
|
+
.It Ev NO_COLOR
|
216
|
+
Assigning a value to it disables colorization.
|
217
|
+
.Pp
|
218
|
+
.It Ev IRB_USE_AUTOCOMPLETE
|
219
|
+
Assigning
|
220
|
+
.Sy false
|
221
|
+
to it disables autocompletion.
|
222
|
+
.Pp
|
223
|
+
.It Ev IRB_COMPLETOR
|
224
|
+
Autocompletion behavior. Allowed values are
|
225
|
+
.Sy regexp
|
226
|
+
or
|
227
|
+
.Sy type
|
228
|
+
.
|
229
|
+
.Pp
|
197
230
|
.El
|
198
231
|
.Pp
|
199
232
|
Also
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reline
|