You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (JIRA)" <ji...@apache.org> on 2012/05/10 14:27:49 UTC
[jira] [Commented] (CLI-225) Special properties option
(-Dproperty=value) handled improperly
[ https://issues.apache.org/jira/browse/CLI-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13272274#comment-13272274 ]
Gary D. Gregory commented on CLI-225:
-------------------------------------
Can you submit a patch file with a unit test please?
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira