diff options
author | aycabta <aycabta@gmail.com> | 2020-04-28 17:07:27 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-04-29 19:13:14 +0900 |
commit | 7e5253d15ea1d2cdfc7942213f9c7ba79c3eda2b (patch) | |
tree | e510513658cf6d9a70fac02230d5987c4f2457b2 | |
parent | 3864fbc6d85b834be4567fa1d5bd0dccc4dfd808 (diff) | |
download | ruby-7e5253d15ea1d2cdfc7942213f9c7ba79c3eda2b.tar.gz |
[ruby/irb] Suppress "method redefined" warning
https://github.com/ruby/irb/commit/5f0aee56fa
-rw-r--r-- | lib/irb/extend-command.rb | 9 |
1 files 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 |