summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-08-08 20:48:23 +0900
committeraycabta <aycabta@gmail.com>2020-08-18 14:38:01 +0900
commit126e1fc2961150a7026b9911a1ed82dbf9557af7 (patch)
tree48eace45728ad58c80ad3c9c45ed1b449bcd21eb /lib
parentef498a016b496c20e45dfeaa3064f8033f420336 (diff)
[ruby/irb] Make history infinite if set SAVE_HISTORY to negative
https://github.com/ruby/irb/commit/824473e880
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/ext/save-history.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index 2d9808259d..3a0703a72c 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -89,7 +89,7 @@ module IRB
def save_history
return unless self.class.const_defined?(:HISTORY)
history = self.class::HISTORY
- if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
+ 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
@@ -110,7 +110,7 @@ module IRB
open(history_file, "w:#{IRB.conf[:LC_MESSAGES].encoding}", 0600) do |f|
hist = history.map{ |l| l.split("\n").join("\\\n") }
begin
- hist = hist.last(num) if hist.size > num
+ hist = hist.last(num) if hist.size > num and num > 0
rescue RangeError # bignum too big to convert into `long'
# Do nothing because the bignum should be treated as inifinity
end