我的代码中包含以下内容。但是当它到达 if 块时,如果条件的计算结果为true,则执行打印功能但退出功能不执行。它只是被跳过了。是因为if条件中的一些错误吗?或者我必须分享我的完整代码吗?
if ( grep -i ERROR /tmp/swm_pkg_ros )
then
print "\nFailed. ...EXITING"
print "\n....you will need to fix the problem and rerun\n"
exit
else
print "Successful"
fi
答案 0 :(得分:0)
它适用于我:
if ( grep -i ERROR /tmp/swm_pkg_ros )
then
echo -e "\nFailed. ...EXITING\n....you will need to fix the problem and rerun"
exit 1
else
echo "Successful"
fi
您可以打印退出代码echo $?