Project

General

Profile

Actions

Bug #12438

closed

OptParse: Short style switch with range does not work

Added by vo.x (Vit Ondruch) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
[ruby-core:75773]

Description

This does not seems to be working:

$ irb
irb(main):001:0> require 'optparse'
irb(main):002:0> o = OptionParser.new
irb(main):003:0> o.on('-[a-z]') {}
irb(main):004:0> o.parse('-f')
NoMethodError: undefined method `size' for nil:NilClass
	from /usr/share/ruby/optparse.rb:433:in `block in complete'
	from /usr/share/ruby/optparse.rb:433:in `each'
	from /usr/share/ruby/optparse.rb:433:in `sort_by'
	from /usr/share/ruby/optparse.rb:433:in `complete'
	from /usr/share/ruby/optparse.rb:838:in `complete'
	from /usr/share/ruby/optparse.rb:1694:in `block in visit'
	from /usr/share/ruby/optparse.rb:1693:in `reverse_each'
	from /usr/share/ruby/optparse.rb:1693:in `visit'
	from /usr/share/ruby/optparse.rb:1725:in `block in complete'
	from /usr/share/ruby/optparse.rb:1724:in `catch'
	from /usr/share/ruby/optparse.rb:1724:in `complete'
	from /usr/share/ruby/optparse.rb:1553:in `block in parse_in_order'
	from /usr/share/ruby/optparse.rb:1527:in `catch'
	from /usr/share/ruby/optparse.rb:1527:in `parse_in_order'
	from /usr/share/ruby/optparse.rb:1521:in `order!'
	from /usr/share/ruby/optparse.rb:1613:in `permute!'
	from /usr/share/ruby/optparse.rb:1635:in `parse!'
	from /usr/share/ruby/optparse.rb:1624:in `parse'
	from (irb):4
	from /usr/bin/irb:11:in `<main>'

Although it is not clear from the documentation, I'd expect that this should match every short option, but unfortunately, it does not work at all ...

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0