plexus-utils icon indicating copy to clipboard operation
plexus-utils copied to clipboard

The CommandLineUtils.translateCommandline fails to parse inner qoutes

Open KIC opened this issue 7 years ago • 0 comments

Here is a small failing test case using spock:

import org.codehaus.plexus.util.cli.CommandLineUtils
import spock.lang.Specification

class CommandlineCommandTest extends Specification {

    def "test getCommand"() {
        given:
        def command = CommandLineUtils.translateCommandline('exec -s something -e "lala \"lo lo\" lulu" -f $file')

        when:
        def parts = command

        then:
        parts.each {println(it)}
        parts == ["exec", "-s", "something", "-e", "lala \"lo lo\" lulu", "-f", "the.file"]
    }

}

it prints

exec
-s
something
-e
lala lo
lo lulu
-f
$file

while we expect lala "lo lo" lulu to be one string

KIC avatar Jan 22 '18 19:01 KIC