Actions
Bug #20252
closedIncompatibility with the `-h` option in optparse on Ruby 3.4.0dev
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-02-09T12:28:26Z master 08b77dd682) [x86_64-darwin23]
Description
An incompatibility has arisen when using optparse with Ruby 3.4.0dev. Below are the steps to reproduce:
# example.rb
require 'optparse'
OptionParser.new do |opts|
opts.on('--[no-]foo')
end.parse!
Expected (Ruby 3.3 or lower)¶
It is represented as --[no-]foo
.
$ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
$ ruby example.rb -h
Usage: example [options]
--[no-]foo
Actual (Ruby 3.4)¶
It is represented as --foo, --no-foo
.
$ ruby -v
ruby 3.4.0dev (2024-02-09T12:28:26Z master 08b77dd682) [x86_64-darwin23]
$ ruby example.rb -h
Usage: example [options]
--foo, --no-foo
This change is likely due to https://github.com/ruby/optparse/pull/60.
I have a question. Is the alteration in the representation of the -h
option from Ruby 3.4.0dev intentional, or should the representation as it was up to Ruby 3.3 be maintained?
This incompatibility was encountered during RuboCop's CI.
https://github.com/rubocop/rubocop/actions/runs/7845618444/job/21410458812?pr=12657
Actions
Like0
Like0