Alexey Tsvetkov created CLI-225:
-----------------------------------
Summary: 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