summaryrefslogtreecommitdiffstats
path: root/lib/irb/extend-command.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-05 09:41:18 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-05 09:41:18 +0000
commit287facbf5429094fd49619d5504d0b33a32e3152 (patch)
tree0cdd407d8b4a483ffe9ee18d4a12ba7e24cb1502 /lib/irb/extend-command.rb
parent06f945c3067533cd09de814a14a856d5090a9255 (diff)
* lib/irb/extend-command.rb (IRB::ExtendCommandBundle::def_extend_command):
extension commands with optional parameters have been broken because of a spec change of UnboundMethod#arity. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@26021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb/extend-command.rb')
-rw-r--r--lib/irb/extend-command.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 84c4c05e1..862857466 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -126,8 +126,12 @@ module IRB
def #{cmd_name}(*opts, &b)
require "#{load_file}"
arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
- args = (1..arity).map {|i| "arg" + i.to_s }
- args << "*opts" if arity < 0
+ args = []
+ if arity < 0
+ args << "*opts"
+ arity = -arity - 1
+ end
+ args.unshift *(1..arity).map {|i| "arg" + i.to_s }
args << "&block"
args = args.join(", ")
eval <<-"EOS2", binding, __FILE__, __LINE__+1