Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-161

PosixParser doesn't stop the parsing on "--" tokens following an option with an argument

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0
    • 1.3
    • Parser
    • None

    Description

      PosixParser doesn't stop on "--" tokens if the option preceding the token expects an argument. GnuParser is not affected by this issue.

      Test case:

      public void testDoubleHyphenToken() throws Exception
      {
          Options options = new Options();
          options.addOption(OptionBuilder.hasArg().create('n'));
          options.addOption(OptionBuilder.create('m'));
      
          CommandLine cl = parser.parse(options, new String[] { "-n", "--", "-m" });
      
          assertTrue(cl.hasOption("n"));
          assertFalse(cl.hasOption("m"));
      }
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ebourg Emmanuel Bourg
            ebourg Emmanuel Bourg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment