Issue #8306 has been updated by nobu (Nobuyoshi Nakada).

Description updated
Status changed from Open to Rejected
Priority changed from High to Low

Use placed argument "--a_param [A]".
----------------------------------------
Bug #8306: Bug In OptionParser accepted parsing
https://bugs.ruby-lang.org/issues/8306#change-38824

Author: chaye (Roi Illouz)
Status: Rejected
Priority: Low
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=begin
program:
  require 'optparse'

  options = {}
  OptionParser.new do |opts|
    opts.on("-a", "--a_param A",  "A") do |a|
       options[:a] = a
    end
    opts.on("-b", "--b_param B", "B") do |b|
       options[:b] = b
    end
  end.parse!

  puts options
  puts ARGV

When adding ops with mandatory params  running
  ./example.rb -a -b x
  options: {:a=>"-b"}
  ARGV: x

Result should not be greedy -a with no param should raise an exception just like C getopts
Using optional params instead of mandatory yields correct results.
=end



-- 
http://bugs.ruby-lang.org/