Bug #1407
closedRuby 1.9.1でのoptparseの挙動がおかしい
Description
=begin
Ruby 1.9.1でのoptparse.rbの挙動がおかしいです。Ruby 1.8.7の挙動が正しいと思います。
$ cat optparse-bug.rb
#!/usr/local/bin/ruby
require 'optparse'
require 'optparse/time'
opts = {}
ARGV.options do |o|
o.on("-T [level]", /^[0-4]$/) {|x| opts[:taint] = x }
o.on("--time X", Time) {|x| opts[:time] = x }
o.parse!
end
puts "#{RUBY_VERSION}: opts=#{opts.inspect}, ARGV=#{ARGV.inspect}"
$ ruby187 optparse-bug.rb -T1 hoge.rb
1.8.7: opts={:taint=>"1"}, ARGV=["hoge.rb"]
$ ruby191 optparse-bug.rb -T1 hoge.rb
1.9.1: opts={:taint=>"1"}, ARGV=["hoge.rb"]
$ ruby187 optparse-bug.rb -T hoge.rb
1.8.7: opts={:taint=>nil}, ARGV=["hoge.rb"]
$ ruby191 optparse-bug.rb -T hoge.rb
Usage: optparse-bug [options]
-T [level]
--time X
$ ruby187 optparse-bug.rb -T te.rb
1.8.7: opts={:taint=>nil}, ARGV=["te.rb"]
$ ruby191 optparse-bug.rb -T te.rb
1.9.1: opts={:taint=>nil, :time=>2009-04-26 14:28:07 +0900}, ARGV=[]
=end
Updated by nobu (Nobuyoshi Nakada) over 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23286.
=end