From 055751cbf58c72f32151f1136bd28b1423f54361 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Sun, 24 Sep 2023 11:03:25 +0200 Subject: [PATCH] Fix: prevent infinite loop due when entering invalid commands due to the name suggestions system --- lib/console1984/command_executor.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/console1984/command_executor.rb b/lib/console1984/command_executor.rb index a621e7d..ef5d765 100644 --- a/lib/console1984/command_executor.rb +++ b/lib/console1984/command_executor.rb @@ -101,12 +101,16 @@ def run_command(run_by_user, &block) end def encrypting_error(error) - def error.inspect - Console1984.command_executor.execute_in_protected_mode { super } + if error.respond_to?(:inspect) + def error.inspect + Console1984.command_executor.execute_in_protected_mode { method(:inspect).super_method.call } + end end - def error.to_s - Console1984.command_executor.execute_in_protected_mode { super } + if error.respond_to?(:to_s) + def error.to_s + Console1984.command_executor.execute_in_protected_mode { method(:to_s).super_method.call } + end end error