Project

General

Profile

Actions

Bug #6455

closed

IRB.conf[:RC_NAME_GENERATOR] と IRB.conf[:SAVE_HISTORY] を同時に設定すると irb が起動できないのを修正する

Added by sho-h (Sho Hashimoto) almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
Backport:
[ruby-dev:45654]

Description

るりまを書いている最中に気づいたのですが、IRB.conf[:RC_NAME_GENERATOR] と IRB.conf[:SAVE_HISTORY] を同時に設定すると irb の起動時にヒストリファイルの読み込みで例外が発生して irb が起動できません。

$ irb
/usr/lib/ruby/1.8/irb/ext/save-history.rb:77:in exist?': can't convert nil into String (TypeError) from /usr/lib/ruby/1.8/irb/ext/save-history.rb:77:in load_history'
...
$

IRB.rc_file("_history") が nil を返すようになるためではないかと思います。

$ irb -f
irb(main):001:0> IRB.conf[:RC_NAME_GENERATOR] = Proc.new { |rc|
irb(main):002:1* ["/tmp/myirb.#{rc}"].detect { |path| File.exists?(path) }
irb(main):003:1> }
irb(main):004:0> IRB.rc_file("_history")
=> nil

1.8.7 で試しましたが、trunk でも同様ではないかと思います。

lib/irb/ext/save-history.rb で IRB.rc_file("_history") が nil であればデフォルト値を使うなどされた方がいいかもしれません。

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0