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

[cli] Parser breaks up command line parms into single characters

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1
    • Component/s: CLI-1.x
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Bugzilla Id:
      32525

      Description

      The base Parser class used to pull tokens from a command line breaks up
      command line options longer than 1 character. For example, -file becomes -f -
      i -l -e. This can be duplicated with the Ant example shown in the user guide.
      This is probably the cause for bug
      http://issues.apache.org/bugzilla/show_bug.cgi?id=31464 section 1 and 2.

      I have worked up a patch that fixes this problem and all of the JUnit tests
      run correctly after this patch is applied.

      There appear to be some shortcomings in the way the Parser class processes
      options. The main problem is that it doesn't maintain a state value indicating
      what is being processed so option parameters can be interpreted as options. To
      fix this the code needs to be reorganized. Because of this, I can't say this
      patch will work in every case but it is an improvement.

        Activity

        Hide
        dmorris@plumcreek.com David Morris added a comment -

        Created an attachment (id=13645)
        Prevents valid options from being broken up int single char options

        This patch will prevent options like -file from being broken up into -f -i -l
        -e as long as -file is the name of a defined option.

        Show
        dmorris@plumcreek.com David Morris added a comment - Created an attachment (id=13645) Prevents valid options from being broken up int single char options This patch will prevent options like -file from being broken up into -f -i -l -e as long as -file is the name of a defined option.
        Hide
        dmorris@plumcreek.com David Morris added a comment -

        Created an attachment (id=13842)
        Demonstrate this patch fixes COM-1176

        The original patch for this bug also fixes COM-1176 as deminstrated by this
        patch.

        Show
        dmorris@plumcreek.com David Morris added a comment - Created an attachment (id=13842) Demonstrate this patch fixes COM-1176 The original patch for this bug also fixes COM-1176 as deminstrated by this patch.
        Hide
        dmorris@plumcreek.com David Morris added a comment -

        The first patch also fixes COM-1176, which is demonstrated by the unit test
        supplied by the second patch.

        Show
        dmorris@plumcreek.com David Morris added a comment - The first patch also fixes COM-1176 , which is demonstrated by the unit test supplied by the second patch.
        Hide
        roxspring Rob Oxspring added a comment -

        Applied with minor alterations to avoid tickling #25044 who's patch hasn't been
        reviewed yet.

        Thanks,

        Rob

        Show
        roxspring Rob Oxspring added a comment - Applied with minor alterations to avoid tickling #25044 who's patch hasn't been reviewed yet. Thanks, Rob

          People

          • Assignee:
            Unassigned
            Reporter:
            dmorris@plumcreek.com David Morris
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development