Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么是-";在ant exec任务中是什么意思?_Ant - Fatal编程技术网

什么是-";在ant exec任务中是什么意思?

什么是-";在ant exec任务中是什么意思?,ant,Ant,这是两个ant任务: <target name="hg.add" > <exec dir="." executable="hg"> <arg line="add ${reports-summary}" /> </exec> </target> <target name="hg.add"> <exec executable="/bin/sh">

这是两个ant任务:

 <target name="hg.add" >
    <exec dir="." executable="hg">
        <arg line="add ${reports-summary}" />
    </exec>
</target>


<target name="hg.add">
      <exec executable="/bin/sh">
            <arg value="-c"/>
            <arg value="hg add ${reports-summary}"/>
      </exec>
</target>


这两项任务似乎具有相同的功能。但是为什么第二个需要写“/bin/sh”和“-c”?

c只是可执行文件的一个参数,它对ant exec任务没有任何特殊意义

第一个目标是直接运行
hg
可执行文件

第二个目标是运行Linux/Unix shell命令(
/bin/sh
),并向其传递
-c
参数,该参数告诉shell执行下一个参数中给出的命令。因此,这将运行与第一个目标相同的命令,但是shell命令可能会在运行命令之前设置环境变量之类的内容