Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从 shell 脚本运行 ant 脚本,如果 ant 脚本成功执行,我必须获得返回码 0 或失败的情况下 1。谁能告诉我如何实现?
cd ~/yoursourcedir/ ant if [[ $? -ne 0 ]] then echo "error happend" fi
$?包含上一个命令的错误代码,在本例中为ant. -ne 0表示不等于 0,所以如果发生任何错误,请执行echo.
$?
ant
-ne 0
echo
您可以为 ant 指定标准参数,即您的构建文件:
ant -buildfile build.xml
ant run 选项总结