Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test a URL in bash script and exit on failure or return failure exit code.
#! /bin/bash
set -o errexit
curl --fail --show-error --location http://httpbin.org/status/200 > /dev/null
echo "It worked!"
curl --fail --show-error --location http://httpbin.org/status/500 > /dev/null
echo "It failed, but you will never see this message."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment