[
https://issues.apache.org/jira/browse/CLI-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487315#comment-13487315
]
Emmanuel Bourg commented on CLI-225:
------------------------------------
Thank you for the report Alexey. A test case would really help figuring out the
issue. The parser has been revamped in the upcoming 1.3 version, could you
please try again with the DefaultParser instead and let us know if the issue
still exists?
> Special properties option (-Dproperty=value) handled improperly
> ---------------------------------------------------------------
>
> Key: CLI-225
> URL: https://issues.apache.org/jira/browse/CLI-225
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.2
> Reporter: Alexey Tsvetkov
>
> In CLI 1.2 the special properties option (-Dproperty=value) is handled
> improperly. In GnuParser.java from line 80 is as follows:
> {code}
> if (opt.indexOf('=') != -1 &&
> options.hasOption(opt.substring(0, opt.indexOf('='))))
> {
> // the format is --foo=value or -foo=value
> tokens.add(arg.substring(0, arg.indexOf('='))); //
> --foo
> tokens.add(arg.substring(arg.indexOf('=') + 1)); //
> value
> }
> else if (options.hasOption(arg.substring(0, 2)))
> {
> // the format is a special properties option
> (-Dproperty=value)
> tokens.add(arg.substring(0, 2)); // -D
> tokens.add(arg.substring(2)); // property=value
> }
> {code}
> , but should be:
> {code}
> if (opt.indexOf('=') != -1)
> {
> if (options.hasOption(opt.substring(0,
> opt.indexOf('='))))
> {
> // the format is --foo=value or -foo=value
> tokens.add(arg.substring(0, arg.indexOf('=')));
> // --foo
> tokens.add(arg.substring(arg.indexOf('=') +
> 1)); // value
> }
> else if (options.hasOption(arg.substring(0, 2)))
> {
> // the format is a special properties option
> (-Dproperty=value)
> tokens.add(arg.substring(0, 2)); // -D
> tokens.add(arg.substring(2)); // property=value
> }
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira