summaryrefslogtreecommitdiff
path: root/lib/irb/history.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/history.rb')
-rw-r--r--lib/irb/history.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/irb/history.rb b/lib/irb/history.rb
index 2489f7403f..685354b2d8 100644
--- a/lib/irb/history.rb
+++ b/lib/irb/history.rb
@@ -16,8 +16,8 @@ module IRB
if history_file = IRB.conf[:HISTORY_FILE]
history_file = File.expand_path(history_file)
end
- history_file = IRB.rc_files("_history").first unless history_file
- if File.exist?(history_file)
+ history_file = IRB.rc_file("_history") unless history_file
+ if history_file && File.exist?(history_file)
File.open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
f.each { |l|
l = l.chomp
@@ -41,7 +41,10 @@ module IRB
if history_file = IRB.conf[:HISTORY_FILE]
history_file = File.expand_path(history_file)
end
- history_file = IRB.rc_files("_history").first unless history_file
+ history_file = IRB.rc_file("_history") unless history_file
+
+ # When HOME and XDG_CONFIG_HOME are not available, history_file might be nil
+ return unless history_file
# Change the permission of a file that already exists[BUG #7694]
begin