From 76b620b341b54eb80028f03cc828333defacc87e Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sat, 11 Jan 2025 22:03:54 +0800 Subject: [ruby/irb] `IRB.conf[:SAVE_HISTORY]` should handle boolean values (https://github.com/ruby/irb/pull/1062) Although not documented, `IRB.conf[:SAVE_HISTORY]` used to accept boolean, which now causes `NoMethodError` when used. This commit changes the behavior to accept boolean values and adds tests for the behavior. https://github.com/ruby/irb/commit/8b1a07b2a8 --- lib/irb/history.rb | 4 ++++ lib/irb/init.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/irb/history.rb b/lib/irb/history.rb index 25fa71b9c3..0beff15539 100644 --- a/lib/irb/history.rb +++ b/lib/irb/history.rb @@ -2,9 +2,13 @@ require "pathname" module IRB module History + DEFAULT_ENTRY_LIMIT = 1000 + class << self # Integer representation of IRB.conf[:HISTORY_FILE]. def save_history + return 0 if IRB.conf[:SAVE_HISTORY] == false + return DEFAULT_ENTRY_LIMIT if IRB.conf[:SAVE_HISTORY] == true IRB.conf[:SAVE_HISTORY].to_i end diff --git a/lib/irb/init.rb b/lib/irb/init.rb index d474bd41d6..b41536e61a 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -93,7 +93,7 @@ module IRB # :nodoc: @CONF[:VERBOSE] = nil @CONF[:EVAL_HISTORY] = nil - @CONF[:SAVE_HISTORY] = 1000 + @CONF[:SAVE_HISTORY] = History::DEFAULT_ENTRY_LIMIT @CONF[:BACK_TRACE_LIMIT] = 16 -- cgit v1.2.3