irb 1.4.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c52cb722e3095862479d2b3238107929c9aacb7d0abdaef02a3ae11ad4d81be
4
- data.tar.gz: f933953b4a52be77dad05d3f39f4a590f08593c4c29782086c1d59c2f00fc9d5
3
+ metadata.gz: 25f63261bbf06e8b1605b8a680e538dd90641ad2492c0bfb0f8e127f673e2793
4
+ data.tar.gz: 9f113f6c97887e83f9d476dba5e4c0a5656d76cc554e1e818c94e8828b4051fa
5
5
  SHA512:
6
- metadata.gz: a6ab46115c8484ec6818876b7a00fd264b3981be71b9a86d0fe4964ea670685ebb6e15bc3d1a6cdc6a0699883088cc75027c77fa67b2f8098c45226d19348f25
7
- data.tar.gz: 346676856d7c18ad4ac921aa2be2669b988752585ea147283674d614b5646574b7eb7127f9a488e1fe2d1519875674fe18f4daa1179d145fcb333ae2d17b70e0
6
+ metadata.gz: 024d8e4dc13978bbae5ed3404e3ecff763da3fcc01e26c43d3e7e54822121bbc708de49c5a9c951a15c0ceee05a60cf282cbbd6ae6ec42960e9a8943a9217417
7
+ data.tar.gz: 146edac46f0d81a01e120493e56eefa8d8b51143851718876617673bcbddf19b54e246d55541833101926e17186ce55b6484e2fb20e6f57735ee49ddfe0b6890
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ group :development do
10
10
  gem "rake"
11
11
  gem "stackprof" if is_unix && !is_truffleruby
12
12
  gem "test-unit"
13
+ gem "reline", github: "ruby/reline" if ENV["WITH_LATEST_RELINE"] == "true"
13
14
  end
data/README.md CHANGED
@@ -40,6 +40,10 @@ irb(main):006:1> end
40
40
 
41
41
  The Readline extension module can be used with irb. Use of Readline is default if it's installed.
42
42
 
43
+ ## Documentation
44
+
45
+ https://docs.ruby-lang.org/en/master/IRB.html
46
+
43
47
  ## Development
44
48
 
45
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/irb.gemspec CHANGED
@@ -8,8 +8,8 @@ end
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = "irb"
10
10
  spec.version = IRB::VERSION
11
- spec.authors = ["Keiju ISHITSUKA"]
12
- spec.email = ["keiju@ruby-lang.org"]
11
+ spec.authors = ["aycabta", "Keiju ISHITSUKA"]
12
+ spec.email = ["aycabta@gmail.com", "keiju@ruby-lang.org"]
13
13
 
14
14
  spec.summary = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
15
15
  spec.description = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
data/lib/irb/cmd/chws.rb CHANGED
@@ -13,8 +13,9 @@
13
13
  require_relative "nop"
14
14
  require_relative "../ext/change-ws"
15
15
 
16
- # :stopdoc:
17
16
  module IRB
17
+ # :stopdoc:
18
+
18
19
  module ExtendCommand
19
20
 
20
21
  class CurrentWorkingWorkspace < Nop
@@ -30,5 +31,6 @@ module IRB
30
31
  end
31
32
  end
32
33
  end
34
+
35
+ # :startdoc:
33
36
  end
34
- # :startdoc:
data/lib/irb/cmd/fork.rb CHANGED
@@ -10,9 +10,11 @@
10
10
  #
11
11
  #
12
12
 
13
+ require_relative "nop"
13
14
 
14
- # :stopdoc:
15
15
  module IRB
16
+ # :stopdoc:
17
+
16
18
  module ExtendCommand
17
19
  class Fork < Nop
18
20
  def execute
@@ -33,5 +35,6 @@ module IRB
33
35
  end
34
36
  end
35
37
  end
38
+
39
+ # :startdoc:
36
40
  end
37
- # :startdoc:
data/lib/irb/cmd/help.rb CHANGED
@@ -11,8 +11,9 @@
11
11
 
12
12
  require_relative "nop"
13
13
 
14
- # :stopdoc:
15
14
  module IRB
15
+ # :stopdoc:
16
+
16
17
  module ExtendCommand
17
18
  class Help < Nop
18
19
  def execute(*names)
@@ -43,5 +44,6 @@ module IRB
43
44
  end
44
45
  end
45
46
  end
47
+
48
+ # :startdoc:
46
49
  end
47
- # :startdoc:
data/lib/irb/cmd/info.rb CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  require_relative "nop"
4
4
 
5
- # :stopdoc:
6
5
  module IRB
6
+ # :stopdoc:
7
+
7
8
  module ExtendCommand
8
9
  class Info < Nop
9
10
  def execute
@@ -28,5 +29,6 @@ module IRB
28
29
  end
29
30
  end
30
31
  end
32
+
33
+ # :startdoc:
31
34
  end
32
- # :startdoc:
data/lib/irb/cmd/load.rb CHANGED
@@ -13,8 +13,9 @@
13
13
  require_relative "nop"
14
14
  require_relative "../ext/loader"
15
15
 
16
- # :stopdoc:
17
16
  module IRB
17
+ # :stopdoc:
18
+
18
19
  module ExtendCommand
19
20
  class Load < Nop
20
21
  include IrbLoader
@@ -63,5 +64,5 @@ module IRB
63
64
  end
64
65
  end
65
66
 
67
+ # :startdoc:
66
68
  end
67
- # :startdoc:
data/lib/irb/cmd/ls.rb CHANGED
@@ -4,8 +4,9 @@ require "reline"
4
4
  require_relative "nop"
5
5
  require_relative "../color"
6
6
 
7
- # :stopdoc:
8
7
  module IRB
8
+ # :stopdoc:
9
+
9
10
  module ExtendCommand
10
11
  class Ls < Nop
11
12
  def execute(*arg, grep: nil)
@@ -97,5 +98,6 @@ module IRB
97
98
  private_constant :Output
98
99
  end
99
100
  end
101
+
102
+ # :startdoc:
100
103
  end
101
- # :startdoc:
@@ -1,7 +1,8 @@
1
1
  require_relative "nop"
2
2
 
3
- # :stopdoc:
4
3
  module IRB
4
+ # :stopdoc:
5
+
5
6
  module ExtendCommand
6
7
  class Measure < Nop
7
8
  def initialize(*args)
@@ -39,5 +40,6 @@ module IRB
39
40
  end
40
41
  end
41
42
  end
43
+
44
+ # :startdoc:
42
45
  end
43
- # :startdoc:
data/lib/irb/cmd/nop.rb CHANGED
@@ -9,8 +9,9 @@
9
9
  #
10
10
  #
11
11
  #
12
- # :stopdoc:
13
12
  module IRB
13
+ # :stopdoc:
14
+
14
15
  module ExtendCommand
15
16
  class Nop
16
17
 
@@ -41,5 +42,6 @@ module IRB
41
42
  end
42
43
  end
43
44
  end
45
+
46
+ # :startdoc:
44
47
  end
45
- # :startdoc:
@@ -13,8 +13,9 @@
13
13
  require_relative "nop"
14
14
  require_relative "../ext/workspaces"
15
15
 
16
- # :stopdoc:
17
16
  module IRB
17
+ # :stopdoc:
18
+
18
19
  module ExtendCommand
19
20
  class Workspaces < Nop
20
21
  def execute(*obj)
@@ -36,5 +37,6 @@ module IRB
36
37
  end
37
38
  end
38
39
  end
40
+
41
+ # :startdoc:
39
42
  end
40
- # :startdoc:
@@ -4,8 +4,9 @@ require_relative "nop"
4
4
  require_relative "../color"
5
5
  require_relative "../ruby-lex"
6
6
 
7
- # :stopdoc:
8
7
  module IRB
8
+ # :stopdoc:
9
+
9
10
  module ExtendCommand
10
11
  class ShowSource < Nop
11
12
  def execute(str = nil)
@@ -89,5 +90,6 @@ module IRB
89
90
  private_constant :Source
90
91
  end
91
92
  end
93
+
94
+ # :startdoc:
92
95
  end
93
- # :startdoc:
@@ -12,8 +12,9 @@
12
12
  require_relative "nop"
13
13
  require_relative "../ext/multi-irb"
14
14
 
15
- # :stopdoc:
16
15
  module IRB
16
+ # :stopdoc:
17
+
17
18
  module ExtendCommand
18
19
  class IrbCommand < Nop
19
20
  def execute(*obj)
@@ -39,5 +40,6 @@ module IRB
39
40
  end
40
41
  end
41
42
  end
43
+
44
+ # :startdoc:
42
45
  end
43
- # :startdoc:
@@ -2,8 +2,9 @@
2
2
 
3
3
  require_relative "nop"
4
4
 
5
- # :stopdoc:
6
5
  module IRB
6
+ # :stopdoc:
7
+
7
8
  module ExtendCommand
8
9
  class Whereami < Nop
9
10
  def execute(*)
@@ -16,5 +17,6 @@ module IRB
16
17
  end
17
18
  end
18
19
  end
20
+
21
+ # :startdoc:
19
22
  end
20
- # :startdoc:
data/lib/irb/color.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'reline'
3
3
  require 'ripper'
4
- require 'irb/ruby-lex'
4
+ require_relative 'ruby-lex'
5
5
 
6
6
  module IRB # :nodoc:
7
7
  module Color
@@ -77,7 +77,15 @@ module IRB # :nodoc:
77
77
 
78
78
  class << self
79
79
  def colorable?
80
- $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
80
+ supported = $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
81
+
82
+ # because ruby/debug also uses irb's color module selectively,
83
+ # irb won't be activated in that case.
84
+ if IRB.respond_to?(:conf)
85
+ supported && IRB.conf.fetch(:USE_COLORIZE, true)
86
+ else
87
+ supported
88
+ end
81
89
  end
82
90
 
83
91
  def inspect_colorable?(obj, seen: {}.compare_by_identity)
@@ -120,10 +128,14 @@ module IRB # :nodoc:
120
128
 
121
129
  symbol_state = SymbolState.new
122
130
  colored = +''
123
- length = 0
124
- end_seen = false
125
131
 
126
132
  scan(code, allow_last_error: !complete) do |token, str, expr|
133
+ # handle uncolorable code
134
+ if token.nil?
135
+ colored << Reline::Unicode.escape_for_print(str)
136
+ next
137
+ end
138
+
127
139
  # IRB::ColorPrinter skips colorizing fragments with any invalid token
128
140
  if ignore_error && ERROR_TOKENS.include?(token)
129
141
  return Reline::Unicode.escape_for_print(code)
@@ -139,15 +151,7 @@ module IRB # :nodoc:
139
151
  colored << line
140
152
  end
141
153
  end
142
- length += str.bytesize
143
- end_seen = true if token == :on___end__
144
- end
145
-
146
- # give up colorizing incomplete Ripper tokens
147
- unless end_seen or length == code.bytesize
148
- return Reline::Unicode.escape_for_print(code)
149
154
  end
150
-
151
155
  colored
152
156
  end
153
157
 
@@ -162,33 +166,42 @@ module IRB # :nodoc:
162
166
  end
163
167
 
164
168
  def scan(code, allow_last_error:)
165
- pos = [1, 0]
166
-
167
169
  verbose, $VERBOSE = $VERBOSE, nil
168
170
  RubyLex.compile_with_errors_suppressed(code) do |inner_code, line_no|
169
171
  lexer = Ripper::Lexer.new(inner_code, '(ripper)', line_no)
170
- if lexer.respond_to?(:scan) # Ruby 2.7+
171
- lexer.scan.each do |elem|
172
- str = elem.tok
173
- next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
174
- next if ([elem.pos[0], elem.pos[1] + str.bytesize] <=> pos) <= 0
172
+ byte_pos = 0
173
+ line_positions = [0]
174
+ inner_code.lines.each do |line|
175
+ line_positions << line_positions.last + line.bytesize
176
+ end
177
+
178
+ on_scan = proc do |elem|
179
+ start_pos = line_positions[elem.pos[0] - 1] + elem.pos[1]
175
180
 
176
- str.each_line do |line|
177
- if line.end_with?("\n")
178
- pos[0] += 1
179
- pos[1] = 0
180
- else
181
- pos[1] += line.bytesize
182
- end
183
- end
181
+ # yield uncolorable code
182
+ if byte_pos < start_pos
183
+ yield(nil, inner_code.byteslice(byte_pos...start_pos), nil)
184
+ end
184
185
 
186
+ if byte_pos <= start_pos
187
+ str = elem.tok
185
188
  yield(elem.event, str, elem.state)
189
+ byte_pos = start_pos + str.bytesize
190
+ end
191
+ end
192
+
193
+ if lexer.respond_to?(:scan) # Ruby 2.7+
194
+ lexer.scan.each do |elem|
195
+ next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
196
+ on_scan.call(elem)
186
197
  end
187
198
  else
188
- lexer.parse.each do |elem|
189
- yield(elem.event, elem.tok, elem.state)
199
+ lexer.parse.sort_by(&:pos).each do |elem|
200
+ on_scan.call(elem)
190
201
  end
191
202
  end
203
+ # yield uncolorable DATA section
204
+ yield(nil, inner_code.byteslice(byte_pos...inner_code.bytesize), nil) if byte_pos < inner_code.bytesize
192
205
  end
193
206
  ensure
194
207
  $VERBOSE = verbose
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'pp'
3
- require 'irb/color'
3
+ require_relative 'color'
4
4
 
5
5
  module IRB
6
6
  class ColorPrinter < ::PP
@@ -37,6 +37,9 @@ module IRB
37
37
  width ||= str.length
38
38
 
39
39
  case str
40
+ when ''
41
+ when ',', '=>', '[', ']', '{', '}', '..', '...', /\A@\w+\z/
42
+ super(str, width)
40
43
  when /\A#</, '=', '>'
41
44
  super(Color.colorize(str, [:GREEN]), width)
42
45
  else
@@ -11,7 +11,29 @@ require_relative 'ruby-lex'
11
11
 
12
12
  module IRB
13
13
  module InputCompletor # :nodoc:
14
+ using Module.new {
15
+ refine ::Binding do
16
+ def eval_methods
17
+ ::Kernel.instance_method(:methods).bind(eval("self")).call
18
+ end
19
+
20
+ def eval_private_methods
21
+ ::Kernel.instance_method(:private_methods).bind(eval("self")).call
22
+ end
23
+
24
+ def eval_instance_variables
25
+ ::Kernel.instance_method(:instance_variables).bind(eval("self")).call
26
+ end
27
+
28
+ def eval_global_variables
29
+ ::Kernel.instance_method(:global_variables).bind(eval("self")).call
30
+ end
14
31
 
32
+ def eval_class_constants
33
+ ::Module.instance_method(:constants).bind(eval("self.class")).call
34
+ end
35
+ end
36
+ }
15
37
 
16
38
  # Set of reserved words used by Ruby, you should not use these for
17
39
  # constants or variables
@@ -60,7 +82,14 @@ module IRB
60
82
  end
61
83
  }
62
84
  }.flatten if defined?(Gem::Specification)
63
- (gem_paths.to_a | $LOAD_PATH).sort
85
+ candidates = (gem_paths.to_a | $LOAD_PATH)
86
+ candidates.map do |p|
87
+ if p.respond_to?(:to_path)
88
+ p.to_path
89
+ else
90
+ String(p) rescue nil
91
+ end
92
+ end.compact.sort
64
93
  end
65
94
 
66
95
  def self.retrieve_files_to_require_from_load_path
@@ -296,10 +325,10 @@ module IRB
296
325
  sep = $2
297
326
  message = $3
298
327
 
299
- gv = eval("global_variables", bind).collect{|m| m.to_s}.push("true", "false", "nil")
300
- lv = eval("local_variables", bind).collect{|m| m.to_s}
301
- iv = eval("instance_variables", bind).collect{|m| m.to_s}
302
- cv = eval("self.class.constants", bind).collect{|m| m.to_s}
328
+ gv = bind.eval_global_variables.collect{|m| m.to_s}.push("true", "false", "nil")
329
+ lv = bind.local_variables.collect{|m| m.to_s}
330
+ iv = bind.eval_instance_variables.collect{|m| m.to_s}
331
+ cv = bind.eval_class_constants.collect{|m| m.to_s}
303
332
 
304
333
  if (gv | lv | iv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
305
334
  # foo.func and foo is var. OR
@@ -349,17 +378,17 @@ module IRB
349
378
 
350
379
  else
351
380
  if doc_namespace
352
- vars = eval("local_variables | instance_variables", bind).collect{|m| m.to_s}
381
+ vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
353
382
  perfect_match_var = vars.find{|m| m.to_s == input}
354
383
  if perfect_match_var
355
384
  eval("#{perfect_match_var}.class.name", bind)
356
385
  else
357
- candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
386
+ candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
358
387
  candidates |= ReservedWords
359
388
  candidates.find{ |i| i == input }
360
389
  end
361
390
  else
362
- candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
391
+ candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
363
392
  candidates |= ReservedWords
364
393
  candidates.grep(/^#{Regexp.quote(input)}/)
365
394
  end
data/lib/irb/context.rb CHANGED
@@ -22,7 +22,7 @@ module IRB
22
22
  #
23
23
  # The optional +input_method+ argument:
24
24
  #
25
- # +nil+:: uses stdin or Reidline or Readline
25
+ # +nil+:: uses stdin or Reline or Readline
26
26
  # +String+:: uses a File
27
27
  # +other+:: uses this as InputMethod
28
28
  def initialize(irb, workspace = nil, input_method = nil)
@@ -32,7 +32,7 @@ module IRB
32
32
  else
33
33
  @workspace = WorkSpace.new
34
34
  end
35
- @thread = Thread.current if defined? Thread
35
+ @thread = Thread.current
36
36
 
37
37
  # copy of default configuration
38
38
  @ap_name = IRB.conf[:AP_NAME]
@@ -48,12 +48,16 @@ module IRB
48
48
  end
49
49
  if IRB.conf.has_key?(:USE_MULTILINE)
50
50
  @use_multiline = IRB.conf[:USE_MULTILINE]
51
- elsif IRB.conf.has_key?(:USE_REIDLINE) # backward compatibility
52
- @use_multiline = IRB.conf[:USE_REIDLINE]
51
+ elsif IRB.conf.has_key?(:USE_RELINE) # backward compatibility
52
+ @use_multiline = IRB.conf[:USE_RELINE]
53
+ elsif IRB.conf.has_key?(:USE_REIDLINE)
54
+ warn <<~MSG.strip
55
+ USE_REIDLINE is deprecated, please use USE_RELINE instead.
56
+ MSG
57
+ @use_multiline = IRB.conf[:USE_RELINE]
53
58
  else
54
59
  @use_multiline = nil
55
60
  end
56
- @use_colorize = IRB.conf[:USE_COLORIZE]
57
61
  @use_autocomplete = IRB.conf[:USE_AUTOCOMPLETE]
58
62
  @verbose = IRB.conf[:VERBOSE]
59
63
  @io = nil
@@ -84,14 +88,14 @@ module IRB
84
88
  when nil
85
89
  if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
86
90
  # Both of multiline mode and singleline mode aren't specified.
87
- @io = ReidlineInputMethod.new
91
+ @io = RelineInputMethod.new
88
92
  else
89
93
  @io = nil
90
94
  end
91
95
  when false
92
96
  @io = nil
93
97
  when true
94
- @io = ReidlineInputMethod.new
98
+ @io = RelineInputMethod.new
95
99
  end
96
100
  unless @io
97
101
  case use_singleline?
@@ -116,6 +120,10 @@ module IRB
116
120
  end
117
121
  @io = StdioInputMethod.new unless @io
118
122
 
123
+ when '-'
124
+ @io = FileInputMethod.new($stdin)
125
+ @irb_name = '-'
126
+ @irb_path = '-'
119
127
  when String
120
128
  @io = FileInputMethod.new(input_method)
121
129
  @irb_name = File.basename(input_method)
@@ -157,7 +165,7 @@ module IRB
157
165
  # The current input method.
158
166
  #
159
167
  # Can be either StdioInputMethod, ReadlineInputMethod,
160
- # ReidlineInputMethod, FileInputMethod or other specified when the
168
+ # RelineInputMethod, FileInputMethod or other specified when the
161
169
  # context is created. See ::new for more # information on +input_method+.
162
170
  attr_accessor :io
163
171
 
@@ -186,8 +194,6 @@ module IRB
186
194
  attr_reader :use_singleline
187
195
  # Whether colorization is enabled or not.
188
196
  #
189
- # A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
190
- attr_reader :use_colorize
191
197
  # A copy of the default <code>IRB.conf[:USE_AUTOCOMPLETE]</code>
192
198
  attr_reader :use_autocomplete
193
199
  # A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
@@ -325,15 +331,13 @@ module IRB
325
331
  # Alias for #use_singleline
326
332
  alias use_singleline? use_singleline
327
333
  # backward compatibility
328
- alias use_reidline use_multiline
334
+ alias use_reline use_multiline
329
335
  # backward compatibility
330
- alias use_reidline? use_multiline
336
+ alias use_reline? use_multiline
331
337
  # backward compatibility
332
338
  alias use_readline use_singleline
333
339
  # backward compatibility
334
340
  alias use_readline? use_singleline
335
- # Alias for #use_colorize
336
- alias use_colorize? use_colorize
337
341
  # Alias for #use_autocomplete
338
342
  alias use_autocomplete? use_autocomplete
339
343
  # Alias for #rc
@@ -347,7 +351,7 @@ module IRB
347
351
  # Returns whether messages are displayed or not.
348
352
  def verbose?
349
353
  if @verbose.nil?
350
- if @io.kind_of?(ReidlineInputMethod)
354
+ if @io.kind_of?(RelineInputMethod)
351
355
  false
352
356
  elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
353
357
  false
@@ -362,11 +366,11 @@ module IRB
362
366
  end
363
367
 
364
368
  # Whether #verbose? is +true+, and +input_method+ is either
365
- # StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see #io
369
+ # StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
366
370
  # for more information.
367
371
  def prompting?
368
372
  verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
369
- @io.kind_of?(ReidlineInputMethod) ||
373
+ @io.kind_of?(RelineInputMethod) ||
370
374
  (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
371
375
  end
372
376
 
@@ -9,7 +9,6 @@
9
9
  #
10
10
  #
11
11
  #
12
- fail CantShiftToMultiIrbMode unless defined?(Thread)
13
12
 
14
13
  module IRB
15
14
  class JobManager
@@ -107,13 +107,13 @@ module IRB
107
107
  raise
108
108
  end
109
109
 
110
- if File.exist?(history_file) && @loaded_history_mtime &&
110
+ if File.exist?(history_file) &&
111
111
  File.mtime(history_file) != @loaded_history_mtime
112
- history = history[@loaded_history_lines..-1]
112
+ history = history[@loaded_history_lines..-1] if @loaded_history_lines
113
113
  append_history = true
114
114
  end
115
115
 
116
- open(history_file, "#{append_history ? 'a' : 'w'}:#{IRB.conf[:LC_MESSAGES].encoding}", 0600) do |f|
116
+ File.open(history_file, (append_history ? 'a' : 'w'), 0o600, encoding: IRB.conf[:LC_MESSAGES]&.encoding) do |f|
117
117
  hist = history.map{ |l| l.split("\n").join("\\\n") }
118
118
  unless append_history
119
119
  begin