diff options
| author | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-21 15:39:51 +0000 |
|---|---|---|
| committer | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-21 15:39:51 +0000 |
| commit | 60abe19dc124821fd1150091400475a092563d5f (patch) | |
| tree | d2a49be87d24a1ca53b254d286bbfb569d0a7937 /lib | |
| parent | 05a47e886ad486894be6be779b867abfa283935a (diff) | |
| download | ruby-60abe19dc124821fd1150091400475a092563d5f.tar.gz ruby-60abe19dc124821fd1150091400475a092563d5f.tar.xz ruby-60abe19dc124821fd1150091400475a092563d5f.zip | |
* lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/irb/ext/save-history.rb | 44 | ||||
| -rw-r--r-- | lib/irb/init.rb | 4 |
2 files changed, 32 insertions, 16 deletions
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index e3597c621..f9c983ac1 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -47,23 +47,24 @@ module IRB module HistorySavingAbility include Readline - def HistorySavingAbility.create_finalizer - proc do - if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0 - if history_file = IRB.conf[:HISTORY_FILE] - history_file = File.expand_path(history_file) - end - history_file = IRB.rc_file("_history") unless history_file - open(history_file, 'w' ) do |f| - hist = HISTORY.to_a - f.puts(hist[-num..-1] || hist) - end - end - end - end +# def HistorySavingAbility.create_finalizer +# proc do +# if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0 +# if hf = IRB.conf[:HISTORY_FILE] +# file = File.expand_path(hf) +# end +# file = IRB.rc_file("_history") unless file +# open(file, 'w' ) do |f| +# hist = HISTORY.to_a +# f.puts(hist[-num..-1] || hist) +# end +# end +# end +# end def HistorySavingAbility.extended(obj) - ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer) +# ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer) + IRB.conf[:AT_EXIT].push proc{obj.save_history} obj.load_history obj end @@ -79,5 +80,18 @@ module IRB end end end + + def save_history + if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0 + if history_file = IRB.conf[:HISTORY_FILE] + history_file = File.expand_path(history_file) + end + history_file = IRB.rc_file("_history") unless history_file + open(history_file, 'w' ) do |f| + hist = HISTORY.to_a + f.puts(hist[-num..-1] || hist) + end + end + end end end diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 489850a86..f51fd1c0b 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -112,7 +112,9 @@ module IRB # @CONF[:LC_MESSAGES] = "en" @CONF[:LC_MESSAGES] = Locale.new - + + @CONF[:AT_EXIT] = [] + @CONF[:DEBUG_LEVEL] = 1 end |
