[#86787] [Ruby trunk Feature#14723] [WIP] sleepy GC — ko1@...

Issue #14723 has been updated by ko1 (Koichi Sasada).

13 messages 2018/05/01
[#86790] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC — Eric Wong <normalperson@...> 2018/05/01

ko1@atdot.net wrote:

[#87095] [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase — ko1@...

Issue #14767 has been updated by ko1 (Koichi Sasada).

9 messages 2018/05/17

[ruby-core:86874] [Ruby trunk Bug#14728] OptionParser takes other options as argument values

From: nobu@...
Date: 2018-05-04 10:29:05 UTC
List: ruby-core #86874
Issue #14728 has been updated by nobu (Nobuyoshi Nakada).


In common, an argument is determined by the preceding option, consider `grep` command's `-e` option.
If you want to disallow an argument starting with `-`, you'd need to specify a pattern

```ruby
  opts.on("-q","--custom MANDATORY", "custom", /\A(?!-)/) do |x|
    options[:custom] = x
  end
```

or allowed values

```ruby
  opts.on("-q","--custom MANDATORY", "custom", %w[A B C]) do |x|
    options[:custom] = x
  end
```


----------------------------------------
Bug #14728: OptionParser takes other options as argument values
https://bugs.ruby-lang.org/issues/14728#change-71837

* Author: xz0r (xz0r xz0r)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
`test.rb`

~~~ ruby
require 'optparse'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: test.rb [options]"

  opts.on("--verbose", "Run verbosely") do |v|
    options[:verbose] = v
  end
  opts.on("--custom MANDATORY", "custom") do |x|
    options[:custom] = x
  end
end.parse!

p options
~~~

If I run the above script as follows below is output: 

```
$ ruby test.rb --custom --verbose
{:custom=>"--verbose"}
```

This is not the expected behaviour as `--verbose` should not be set as the option value.



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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next