Skip to content

Commit b9df713

Browse files
kwatchnobu
authored andcommitted
Backport from v0.5.0 to fix a bug #74
1 parent acbf6e3 commit b9df713

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/optparse.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,14 +1641,19 @@ def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
16411641
opt, rest = $1, $2
16421642
opt.tr!('_', '-')
16431643
begin
1644-
sw, = complete(:long, opt, true)
1645-
if require_exact && !sw.long.include?(arg)
1646-
throw :terminate, arg unless raise_unknown
1647-
raise InvalidOption, arg
1644+
if require_exact
1645+
sw, = search(:long, opt)
1646+
else
1647+
sw, = complete(:long, opt, true)
16481648
end
16491649
rescue ParseError
16501650
throw :terminate, arg unless raise_unknown
16511651
raise $!.set_option(arg, true)
1652+
else
1653+
unless sw
1654+
throw :terminate, arg unless raise_unknown
1655+
raise InvalidOption, arg
1656+
end
16521657
end
16531658
begin
16541659
opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}

0 commit comments

Comments
 (0)