我有一个bash脚本设置来执行一些curl请求
for currency in EUR INR JPY
do
curl -i --data '{"currency": "'$currency'"}' -H "Accept: application/json" -H "Content-Type: application/json" http://0.0.0.0:8080/price && echo
done
如果其中一个curl响应返回http状态!= 200,是否有办法使脚本退出?
我还希望保留标准的curl输出,例如,我不希望仅打印http状态代码的解决方案。
干杯
--fail
由于以下两个原因而不合适:1Fail silently (no output at all)
.和2This method is not fail-safe and there are occasions where non-successful response codes will slip through
。