Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.5.6
-
None
-
None
-
>>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)>>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)
Description
Stumbled across this edge case upgrading from 2.4.x to 2.5.6. Given the following CliBuilder based script,
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() } """
Passing an option value containing the character combo += can trigger greedy assignment to args. Here is the pre-2.5 behavior.
$ ~/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]
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.
$ 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]
Attachments
Issue Links
- is related to
-
GROOVY-8520 Replace commons-cli with picocli in CliBuilder
- Closed