You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alexey Tsvetkov (JIRA)" <ji...@apache.org> on 2012/05/10 11:05:29 UTC

[jira] [Created] (CLI-225) Special properties option (-Dproperty=value) handled improperly

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

        

[jira] [Commented] (CLI-225) Special properties option (-Dproperty=value) handled improperly

Posted by "Gary D. Gregory (JIRA)" <ji...@apache.org>.
    [ 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

        

[jira] [Commented] (CLI-225) Special properties option (-Dproperty=value) handled improperly

Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
    [ 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