Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using bash glob in gradle exec task

Tags:

bash

gradle

glob

I'm building a gradle Exec task that implies just invoking a basic sed command, let says: sed -i 's:some:substitution:' *

What is the proper syntax or gradle function/variable to make the * glob replaced by the file it would match in some bash/zsh shell?

In other words, how to trigger shell expansion?


What I tried so far is :

task myTask(type: Exec){

    workingDirsome dir

    commandLine 'sed', '-i', 's:some:substitution:', "*"
}

but I get an error: sed: can't read *: No such file or directory , which is not so surprising.

like image 850
AdrieanKhisbe Avatar asked Aug 07 '14 09:08

AdrieanKhisbe


1 Answers

You need to start the command wrapped in a shell:

commandLine 'bash', '-c', 'sed -i "s:some:substitution:" *'
like image 125
hek2mgl Avatar answered Nov 07 '22 00:11

hek2mgl