我有以下代码的一部分:但是当它到达这个if块时,如果条件的计算结果为true,则打印函数被执行,但exit函数不被执行。它被跳过了。是因为if条件出现了错误吗?或者我必须分享我的完整代码?
if ( grep -i ERROR /tmp/swm_pkg_ros )
then
print "nFailed. ...EXITING"
print "n....you will need to fix the problem and rerunn"
exit
else
print "Successful"
fi
这对我来说很好:
if ( grep -i ERROR /tmp/swm_pkg_ros )
then
echo -e "nFailed. ...EXITINGn....you will need to fix the problem and rerun"
exit 1
else
echo "Successful"
fi
您可以打印退出代码echo $?