我正在构建一个gradle Exec
任务,意味着只需调用一个基本sed
命令,让我们说: sed -i 's:some:substitution:' *
什么是正确的语法或gradle函数/变量,以使*
glob在一些bash/zsh shell中匹配的文件替换?
换句话说,如何触发shell扩展?
到目前为止我尝试的是:
task myTask(type: Exec){ workingDirsome dir commandLine 'sed', '-i', 's:some:substitution:', "*" }
但是我得到一个错误:sed: can't read *: No such file or directory
这并不令人惊讶.
您需要启动包装在shell中的命令:
commandLine 'bash', '-c', 'sed -i "s:some:substitution:" *'