[ruby-core:70726] [Ruby trunk - Bug #11523] [Open] optparse short options will match complete options

From: fairnmicha@...
Date: 2015-09-11 16:03:40 UTC
List: ruby-core #70726
Issue #11523 has been reported by Micha J.

----------------------------------------
Bug #11523: optparse short options will match complete options
https://bugs.ruby-lang.org/issues/11523

* Author: Micha J
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
In short, if I define an option like `"-F", "--irs [OCTAL]"`, `-i` will match this option, although the short version is defined as `-F`.

----

In long, this can be quite troublesome:

See the provided example

http://ruby-doc.org/stdlib-2.2.0/libdoc/optparse/rdoc/OptionParser.html

and change or remove the `"-i", "--inplace [EXTENSION]"` option for something else than `i`:

Now, the -i will still match, but the other option `"-F", "--irs [OCTAL]"`!

In a more complete stack this resulted in a hard to find error. Also, to fix this (and raise the required error) you need to check the ARGV directly which renders optparse a bit less useful.




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

In This Thread

Prev Next