Bug #8306

Bug In OptionParser accepted parsing

Added by Roi Illouz about 1 year ago. Updated about 1 year ago.

[ruby-core:54493]
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

Description

=begin
program:
require 'optparse'

options = {}
OptionParser.new do |opts|
opts.on("-a", "--aparam 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

History

#1 Updated by Nobuyoshi Nakada about 1 year ago

  • Description updated (diff)
  • Status changed from Open to Rejected
  • Priority changed from High to Low

Use placed argument "--a_param [A]".

Also available in: Atom PDF