diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 08:49:54 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 08:49:54 +0000 |
commit | 2c490bea5b4eb31ae20386bc88d46d2ff432f407 (patch) | |
tree | bcb3704feecdfca08f8dd273ed5a359861089bab /lib | |
parent | 1a7e21943307a21cc3a70237a85ff7205d6dcd53 (diff) |
merge revision(s) 55228: [Backport #12438]
* lib/optparse.rb (OptionParser::Completion.candidate): get rid of
nil as key names. [ruby-core:75773] [Bug #12438]
* lib/optparse.rb (OptionParser#make_switch): char class option
cannot be NoArgument, default to RequiredArgument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@55364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/optparse.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index 4ec891e3ae..4f7d7c899d 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -268,7 +268,7 @@ class OptionParser candidates = [] block.call do |k, *v| (if Regexp === k - kn = nil + kn = "".freeze k === key else kn = defined?(k.id2name) ? k.id2name : k @@ -1191,6 +1191,7 @@ XXX default_pattern = nil klass = nil q, a = nil + has_arg = false opts.each do |o| # argument class @@ -1269,6 +1270,8 @@ XXX if a default_style = default_style.guess(arg = a) default_pattern, conv = search(:atype, o) unless default_pattern + else + has_arg = true end sdesc << "-#{q}" short << Regexp.new(q) @@ -1291,6 +1294,9 @@ XXX default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern if !(short.empty? and long.empty?) + if has_arg and default_style == Switch::NoArgument + default_style = Switch::RequiredArgument + end s = (style || default_style).new(pattern || default_pattern, conv, sdesc, ldesc, arg, desc, block) elsif !block |