groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: Problem running find execute has error
Date Wed, 12 Jun 2019 02:38:25 GMT
Most folks with anything but the simplest args find the String[] variant of
execute to be easier to use than the String variant.


On Wed, Jun 12, 2019 at 4:05 AM Sverre Moe <sverre.moe@gmail.com> wrote:

> Groovy is doing something strange with my execute command.
> Or perhaps something wrong with my code I cannot see.
>
> vim find.groovy
> def sout = new StringBuilder(), serr = new StringBuilder()
> def proc = "find RPMS -regex '.*/package-name-[0-9.]+-.\\.x86_64\\.rpm'
> -exec cp -v {} . \\;".execute()
> proc.consumeProcessOutput(sout, serr)
> proc.waitForOrKill(1000)
> println "out> $sout"
> println "err> $serr"
>
> Create the directory and files for testing the find.groovy
> mkdir RPMS
> touch RPMS/package-name-1.0.0-1.x86_64.rpm
> touch RPMS/package-name-devel-1.0.0-1.noarch.rpm
>
> The output from running the find.groovy seems to suggest the find command
> is wrong.
> groovy find.groovy
> err> find: argument for «-exec» is missing
>
> But running it in bash works just fine:
> find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} .
> \;
> 'RPMS/package-name-1.0.0-1.x86_64.rpm' ->
> './package-name-1.0.0-1.x86_64.rpm'
>
> I can reproduce the error in Bash with an additional slash at the end.
> find RPMS -regex '.*/package-name-[0-9.]+-.\.x86_64\.rpm' -exec cp -v {} .
> \\;
> find: argument for «-exec» is missing
>
>
> /Sverre
>

Mime
View raw message