Skip to content
Browse files

save history on exception

  • Loading branch information...
1 parent b5599de commit 25563867de4f845b6b293b90befabc84bc9a7e2a @defunkt committed Jun 19, 2009
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/lyndon/repl.rb
View
10 lib/lyndon/repl.rb
@@ -18,8 +18,8 @@ def self.start
begin
puts Result + @parser.eval(input).inspect
rescue => e
- puts "Error: #{e}", e.backtrace
- quit
+ save_history
+ raise e
else
Readline::HISTORY.push(input)
end
@@ -33,10 +33,14 @@ def self.load_history
end
end
- def self.quit
+ def self.save_history
File.open(HistoryFile, 'w') do |f|
f.puts Readline::HISTORY.to_a.join("\n")
end
+ end
+
+ def self.quit
+ save_history
exit
end
end

0 comments on commit 2556386

Please sign in to comment.
Something went wrong with that request. Please try again.