You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2019/05/07 11:34:00 UTC
[jira] [Assigned] (GROOVY-9016) picocli-based CliBuilder can be
tricked into greedily consuming option as an arg
[ https://issues.apache.org/jira/browse/GROOVY-9016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Remko Popma reassigned GROOVY-9016:
-----------------------------------
Assignee: Remko Popma
> 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
> Assignee: Remko Popma
> 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)