Just exit if curl ends with a non-zero exit code:

curl http://www.example.com || exit 1


Or, make your script exit on error:

set -e
curl http://www.example.com


How to stop shell script if curl failed
If I throw a ball upwards to a certain height in an accelerating train, will it end up in my hand? At the moment I release the ball, it will have a velocity equal to that of the train at that instant. But because the train is accelerating, the train will have a greater velocity and thus the ball will travel lesser distance and should fall behind me. Is my reasoning correct?
