Project

General

Profile

Actions

Bug #12438

closed

OptParse: Short style switch with range does not work

Added by vo.x (Vit Ondruch) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
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 #1

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Status changed from Open to Closed

Applied in changeset r55228.


optparse.rb: fix char class option

  • 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.

Updated by usa (Usaku NAKAMURA) almost 5 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED

Updated by usa (Usaku NAKAMURA) almost 5 years ago

  • Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: DONE, 2.3: REQUIRED

ruby_2_2 r55364 merged revision(s) 55228.

Updated by nagachika (Tomoyuki Chikanaga) almost 5 years ago

  • Backport changed from 2.1: WONTFIX, 2.2: DONE, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: DONE, 2.3: DONE

ruby_2_3 r55459 merged revision(s) 55228.

Actions

Also available in: Atom PDF