summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-21 05:55:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-21 05:55:20 +0000
commit6ea2bbc843dc4c64277feb2d51c8e3cf9e12fb44 (patch)
tree5c34534ac7f2d6fac76d639c1c6cf7d6c0df090a /lib
parent3f12dc5a8f56e9c8c8f0c58c48ca682a0c6543d5 (diff)
downloadruby-6ea2bbc843dc4c64277feb2d51c8e3cf9e12fb44.tar.gz
ruby-6ea2bbc843dc4c64277feb2d51c8e3cf9e12fb44.tar.xz
ruby-6ea2bbc843dc4c64277feb2d51c8e3cf9e12fb44.zip
* lib/optparse.rb (SPLAT_PROC): splat values by hand.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/optparse.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 446039116..e52d5d275 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -996,7 +996,7 @@ class OptionParser
end
private :notwice
- SPLAT_PROC = proc {|*a| next *a}
+ SPLAT_PROC = proc {|*a| a.length <= 1 ? a.first : a}
#
# Creates an OptionParser::Switch from the parameters. The parsed argument
# value is passed to the given block, where it can be processed.
@@ -1263,7 +1263,7 @@ class OptionParser
end
begin
opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
- val = cb.call(*val) if cb
+ val = cb.call(val) if cb
setter.call(sw.switch_name, val) if setter
rescue ParseError
raise $!.set_option(arg, rest)
@@ -1294,7 +1294,7 @@ class OptionParser
opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
argv.unshift(opt) if opt and (opt = opt.sub(/\A-*/, '-')) != '-'
- val = cb.call(*val) if cb
+ val = cb.call(val) if cb
setter.call(sw.switch_name, val) if setter
rescue ParseError
raise $!.set_option(arg, arg.length > 2)