Bug #623

optparseでオプションが重複していると--helpと挙動が違う

Added by Kazuhiro NISHIYAMA over 3 years ago. Updated 10 months ago.

[ruby-dev:36692]
Status:Closed Start date:08/08/2008
Priority:Normal Due date:12/24/2008
Assignee:Nobuyoshi Nakada % Done:

100%

Category:-
Target version:1.9.1 Release Candidate
ruby -v:

Description

# バージョンに迷ってredmineに登録していなかった[ruby-dev:35801]の件を
# redmineの方に入れておきます。

opts.onでオプションが重複していると--helpでは
先に出てきた方に対応するように表示されるのに
実際には後に出てきたの方の意味になります。

% cat o.rb
#!/usr/bin/ruby
require 'optparse'
ARGV.options do |opts|
  opts.on("-t", "--test-option"){p "test-option"}
  opts.on("-t", "--another-test-option"){p "another-test-option"}
  opts.parse!
end
% ruby18 -v o.rb -h
ruby 1.8.7 (2008-08-08 revision 0) [i686-linux]
Usage: o [options]
    -t, --test-option
        --another-test-option
% ruby18 -v o.rb -t
ruby 1.8.7 (2008-08-08 revision 0) [i686-linux]
"another-test-option"
% ruby-1.8.6 -v o.rb -t
ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-linux]
"another-test-option"
% ruby-1.8.7 -v o.rb -t
ruby 1.8.7 (2008-08-08 patchlevel 71) [i686-linux]
"another-test-option"
% ruby-trunk -v o.rb -t
ruby 1.9.0 (2008-08-07 revision 18407) [i686-linux]
"another-test-option"
%

Associated revisions

Revision 21066
Added by Nobuyoshi Nakada about 3 years ago

* lib/optparse.rb (OptionParser::List#summarize): gives priority to latter switches. [ruby-dev:36692] * lib/optparse.rb (OptionParser#summarize): do not append unnecessary line terminator.

History

Updated by Yuki Sonoda about 3 years ago

  • Target version set to 1.9.1 Release Candidate

Updated by Yuki Sonoda about 3 years ago

  • Due date set to 12/24/2008

Updated by Nobuyoshi Nakada about 3 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r21066.

Also available in: Atom PDF