From 7e5253d15ea1d2cdfc7942213f9c7ba79c3eda2b Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 28 Apr 2020 17:07:27 +0900 Subject: [PATCH] [ruby/irb] Suppress "method redefined" warning https://github.com/ruby/irb/commit/5f0aee56fa --- lib/irb/extend-command.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 828103ccc9..2f4fcfb5c6 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -173,11 +173,14 @@ module IRB # :nodoc: args << "&block" args = args.join(", ") line = __LINE__; eval %[ - def #{cmd_name}(\#{args}) - ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) + unless self.class.class_variable_defined?(:@@#{cmd_name}_) + self.class.class_variable_set(:@@#{cmd_name}_, true) + def #{cmd_name}_(\#{args}) + ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) + end end ], nil, __FILE__, line - send :#{cmd_name}, *opts, &b + send :#{cmd_name}_, *opts, &b end ], nil, __FILE__, line else