summaryrefslogtreecommitdiff
path: root/lib/irb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-26 15:33:29 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-26 15:33:29 +0000
commit62cc5d4e01b2443cd48fc011affddf331d89301b (patch)
treef8c364356bb2594730bbfe7e4ced7f7c3177bb33 /lib/irb
parent4adce79fa2410fef8b5c32c7c747757c2a580ebb (diff)
merges r24229 and r24233 from trunk into ruby_1_9_1.
-- * 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] -- * lib/irb.rb: forget svn commit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/ext/save-history.rb44
-rw-r--r--lib/irb/init.rb2
2 files changed, 31 insertions, 15 deletions
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index 88610fe9c9..b74c269323 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -49,23 +49,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
@@ -81,6 +82,19 @@ 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 62c862a1c3..efbc1c3c1b 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -113,6 +113,8 @@ module IRB
# @CONF[:LC_MESSAGES] = "en"
@CONF[:LC_MESSAGES] = Locale.new
+ @CONF[:AT_EXIT] = []
+
@CONF[:DEBUG_LEVEL] = 1
end