groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Ray (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-9016) picocli-based CliBuilder can be tricked into greedily consuming option as an arg
Date Sun, 03 Mar 2019 00:19:00 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-9016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Brian Ray updated GROOVY-9016:
------------------------------
    Environment: 
>>First encountered<<
Groovy 2.4.15 - no bug
Groovy 2.5.6 - bug

Win 8.1 Pro
Zulu OpenJDK 1.8.0_202

>>Minimal replication<<
Groovy 2.4.8 (distro package) - no bug
OpenJDK 1.8.0_181 (distro package)
Debian 9/Stretch

groovy:2.5.6-jre8-alpine Docker image - bug
OpenJdk 1.8.0_191 (in image)
Debian 9/Stretch + Alpine 8 (in image)

  was:
>>First encountered<<
Groovy 2.4.15 - no bug
Groovy 2.5.6 - bug

Win 8.1 Pro
Zulu OpenJDK 1.8.0_202

>>Minimal replication<<
Groovy 2.4.8 (distro package) - no bug
OpenJDK 1.8.0_181 (distro package)
Debian 8

groovy:2.5.6-jre8-alpine Docker image - bug
OpenJdk 1.8.0_191 (in image)
Debian 8 + Alpine 8 (in image)


> picocli-based CliBuilder can be tricked into greedily consuming option as an arg
> --------------------------------------------------------------------------------
>
>                 Key: GROOVY-9016
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9016
>             Project: Groovy
>          Issue Type: Bug
>          Components: command line processing
>    Affects Versions: 2.5.6
>         Environment: >>First encountered<<
> Groovy 2.4.15 - no bug
> Groovy 2.5.6 - bug
> Win 8.1 Pro
> Zulu OpenJDK 1.8.0_202
> >>Minimal replication<<
> Groovy 2.4.8 (distro package) - no bug
> OpenJDK 1.8.0_181 (distro package)
> Debian 9/Stretch
> groovy:2.5.6-jre8-alpine Docker image - bug
> OpenJdk 1.8.0_191 (in image)
> Debian 9/Stretch + Alpine 8 (in image)
>            Reporter: Brian Ray
>            Priority: Minor
>
> Stumbled across this edge case upgrading from 2.4.x to 2.5.6. Given the following {{CliBuilder}}
based script,
> {code:java}
> final cli = new CliBuilder()
> cli.with {
>   f(
>     longOpt: "firstOpt",
>     "first option",
>     required: false,
>     args: 1,
>     argName: "firstOpt",
>   )
> }
> final opts = cli.parse(args)
> println """
>   firstOpt=$opts.firstOpt
>   args=${ opts.arguments() }
> """
> {code}
> Passing an option value containing the character combo {{+=}} can trigger greedy assignment
to args. Here is the pre-2.5 behavior.
> {noformat}
> $ ~/cli_greedy_arg.groovy -f+= bat
>   firstOpt=+=
>   args=[bat]
> $ ~/cli_greedy_arg.groovy -f'+=' bat
>   firstOpt=+=
>   args=[bat]
> $ ~/cli_greedy_arg.groovy -f"+=" bat
>   firstOpt=+=
>   args=[bat]
> $ ~/cli_greedy_arg.groovy -f="+=" bat
>   firstOpt==+=
>   args=[bat]
> {noformat}
> That odd option value is captured properly each time.
> Bumping up to 2.5.6 that option value tricks picocli (I'm guessing) into consuming the
opt value as an arg in three out of four attempts.
> {noformat}
> $ docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy:2.5.6-jre8
> -alpine groovy cli_greedy_arg.groovy -f+= bat
>   firstOpt=false
>   args=[-f+=, bat]
> $ docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy:2.5.6-jre8
> -alpine groovy cli_greedy_arg.groovy -f'+=' bat
>   firstOpt=false
>   args=[-f+=, bat]
> $ docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy:2.5.6-jre8
> -alpine groovy cli_greedy_arg.groovy -f"+=" bat
>   firstOpt=false
>   args=[-f+=, bat]
> $ docker run --rm -v "$PWD":/home/groovy/scripts -w /home/groovy/scripts groovy:2.5.6-jre8
> -alpine groovy cli_greedy_arg.groovy -f="+=" bat
>   firstOpt=+=
>   args=[bat]
> {noformat}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message