为什么Shell命令不起作用,因为它应该在shell中正常工作

时间:2014-03-17 20:10:11

标签: bash shell ant

 unset files;
 git --no-pager diff --name-only HEAD HEAD~10 -- '*.php' |
 while IFS= read -r filename; do
     if [[ -f $filename ]]; then
         files+="./$filename,"
     fi
 done

 files="${files%,}" | phpmd "$files" text codesize

这在命令行中完美运行。但后来我在Ant构建脚本中定义它,如下所示:

<target name="phpmd"
        description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
    <exec executable="bash" failonerror="true" >
        <arg value="-c" />
        <arg value="unset files; git --no-pager diff --name-only HEAD HEAD~10 -- '*.php' |  while IFS= read -r filename; do if [[ -f $$filename ]]; then files+=&quot;./$$filename,&quot;; fi; done; files=&quot;$${files%,}&quot; | phpmd &quot;$$files&quot; text codesize" />
    </exec>
</target>

它不起作用......也许有人会知道这个问题是什么?

1 个答案:

答案 0 :(得分:0)

你是否尝试过使用而不仅仅是为了一个不仅仅是一个争论的东西。

例如:

<arg line="unset files; git --no-pager diff --name-only HEAD HEAD~10 -- '*.php' |  while IFS= read -r filename; do if [[ -f $$filename ]]; then files+=&quot;./$$filename,&quot;; fi; done; files=&quot;$${files%,}&quot; | phpmd &quot;$$files&quot; text codesize" />