Project

General

Profile

Actions

Bug #1407

closed

Ruby 1.9.1でのoptparseの挙動がおかしい

Added by rubikitch (rubikitch .) over 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
Backport:
[ruby-dev:38333]

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

Actions #1

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

Actions

Also available in: Atom PDF

Like0
Like0