summaryrefslogtreecommitdiff
path: root/lib/irb/ext/save-history.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-09-14 10:15:32 +0900
committergit <svn-admin@ruby-lang.org>2022-09-14 10:15:45 +0900
commit9299db49f567025e28082be698e1f624b3e3f3ed (patch)
tree4486c06fdb1c0eb555cb6d54e317e667ba40adaa /lib/irb/ext/save-history.rb
parentb876230e5cad02523105d517dce38e1bf1eec5b5 (diff)
[ruby/irb] Fix history file saving with concurrent irb sessions when history file doesn't exist
If history file didn't exist when irb was started, @loaded_history_mtime would be nil. However, if the history file didn't exist before, but it exists when saving history, that means the history file was modified, and we should handle it the same way as we handle the other case where the history file was modified. Fixes #388 https://github.com/ruby/irb/commit/8d277aafcb
Diffstat (limited to 'lib/irb/ext/save-history.rb')
-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 7acaebe36a..ad954c3558 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -107,9 +107,9 @@ module IRB
raise
end
- if File.exist?(history_file) && @loaded_history_mtime &&
+ if File.exist?(history_file) &&
File.mtime(history_file) != @loaded_history_mtime
- history = history[@loaded_history_lines..-1]
+ history = history[@loaded_history_lines..-1] if @loaded_history_lines
append_history = true
end