commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (CLI-260) Opption parsing does not recognize quotes as end of option
Date Sun, 18 Jun 2017 15:05:02 GMT


ASF GitHub Bot commented on CLI-260:

Github user chtompki commented on the issue:
    My impression base on my reading of the [CLI-260](
is that from this code:
      private DefaultParser parser;
      private Options options;
      public void setUp()
        parser = new DefaultParser();
        options = new Options()
          .addOption("a", "enable-a", false, "turn [a] on or off")
          .addOption("b", "bfile", true, "set the value of [b]")
          .addOption("c", "copt", false, "turn [c] on or off")
          .addOption("k", "kopt", true, "set value of k");
      public void testProblem() throws Exception
        String[] args = new String[] {"-k'option=value'"};
        CommandLine cl = parser.parse(options, args);
        String temp = "temp";
    we get this exception:
    org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -k'option=value'
    	at org.apache.commons.cli.DefaultParser.handleUnknownToken(
    	at org.apache.commons.cli.DefaultParser.handleLongOptionWithEqual(
    	at org.apache.commons.cli.DefaultParser.handleShortAndLongOption(
    	at org.apache.commons.cli.DefaultParser.handleToken(
    	at org.apache.commons.cli.DefaultParser.parse(
    	at org.apache.commons.cli.DefaultParser.parse(
    	at org.apache.commons.cli.DefaultParser.parse(
    	at org.apache.commons.cli.bug.BugCLI260Test.testProblem(
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
    	at java.base/java.lang.reflect.Method.invoke(
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    	at org.junit.internal.runners.statements.RunBefores.evaluate(
    	at org.junit.runners.ParentRunner.runLeaf(
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    	at org.junit.runners.ParentRunner$
    	at org.junit.runners.ParentRunner$1.schedule(
    	at org.junit.runners.ParentRunner.runChildren(
    	at org.junit.runners.ParentRunner.access$000(
    	at org.junit.runners.ParentRunner$2.evaluate(
    	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(
    	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
    	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(
    	at com.intellij.rt.execution.junit.JUnitStarter.main(
    @jlm429, @britter - thoughts?

> Opption parsing does not recognize quotes as end of option
> ----------------------------------------------------------
>                 Key: CLI-260
>                 URL:
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x
>    Affects Versions: 1.3.1
>            Reporter: Ralf Edmund Stranzenbach
>            Assignee: Rob Tompkins
> A command String like
>     *-k'option=value'*
> does not recognize the string *option=value* as the parameter of *-k*.
> Instead *-k'option* is parsed as the option and *value* as parameter.
> Workaround: use *-k='option=value'* instead. But users might think otherwise.

This message was sent by Atlassian JIRA

View raw message