[#50466] [ruby-trunk - Bug #7492][Open] Segmentation fault at DL::TestDL#test_call_double on x64 Windows 8 — "phasis68 (Heesob Park)" <phasis@...>

23 messages 2012/12/02

[#50558] [ruby-trunk - Feature #7511][Open] short-circuiting logical implication operator — "rits (First Last)" <redmine@...>

12 messages 2012/12/04

[#50575] [ruby-trunk - Feature #7517][Open] Fixnum::MIN,MAX — "matz (Yukihiro Matsumoto)" <matz@...>

20 messages 2012/12/05

[#50755] Becoming a committer — Charlie Somerville <charlie@...>

Hi ruby-core,

21 messages 2012/12/11
[#50759] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50784] Re: Becoming a committer — Charles Oliver Nutter <headius@...> 2012/12/11

It's really this easy? If so, I'll send over my public key today :)

[#50795] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50806] [ruby-trunk - Feature #7548][Open] Load and Require Callbacks — "trans (Thomas Sawyer)" <transfire@...>

12 messages 2012/12/12

[#50810] [ruby-trunk - Feature #7549][Open] A Ruby Design Process — "brixen (Brian Ford)" <brixen@...>

34 messages 2012/12/12

[#50867] [ruby-trunk - Bug #7556][Assigned] test error on refinement — "usa (Usaku NAKAMURA)" <usa@...>

14 messages 2012/12/13

[#50900] [ruby-trunk - Bug #7564][Open] r38175 introduces incompatibility — "tenderlovemaking (Aaron Patterson)" <aaron@...>

14 messages 2012/12/14

[#50951] [ruby-trunk - Bug #7584][Open] Ruby hangs when shutting down an ssl connection in gc finalization — "bpot (Bob Potter)" <bobby.potter@...>

12 messages 2012/12/17

[#51076] [ruby-trunk - Feature #7604][Open] Make === comparison operator ability to delegate comparison to an argument — "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>

12 messages 2012/12/22

[#51170] [ruby-trunk - Bug #7629][Open] Segmentation fault — "atd (Antonio Tapiador)" <atapiador@...>

13 messages 2012/12/28

[ruby-core:50715] [ruby-trunk - Bug #7537] OptionParser treats negative digits as options

From: "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>
Date: 2012-12-09 14:12:27 UTC
List: ruby-core #50715
Issue #7537 has been updated by prijutme4ty (Ilya Vorontsov).


In my opinion, negative numbers shouldn't be treated as option keys unless it was explicitly specified. In other cases them should be treated as usual parameters.
----------------------------------------
Bug #7537: OptionParser treats negative digits as options
https://bugs.ruby-lang.org/issues/7537#change-34562

Author: prijutme4ty (Ilya Vorontsov)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9.3(p0, p327 both)


Is it intentional that negative digits are treated as options?
If I use negative digit as an argument of an option, it is treated as a number

OptionParser.new {|opts|
  opts.on('-p','--pvalue VAL', Integer, 'P-value') {|v|  puts "P-value: #{v}" }
}.parse!

`ruby my_test.rb -p -1` works normally

But if I use it as optional argument of an option:

OptionParser.new {|opts|
  opts.on('-p','--pvalue [VAL]', Integer, 'P-value') {|v|  puts "P-value: #{v}" }
}.parse!

`ruby my_test.rb -p -1` fails with "Invalid option -1"

Also I can't use it as non-optional argument

OptionParser.new {|opts|
  opts.on('-n', 'no Pvalue argument, other arguments only') {}
}.parse!
puts ARGV

`ruby my_test.rb -1` also fails with "Invalid option -1"


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

In This Thread