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

Reply via email to