Skip to content

Instantly share code, notes, and snippets.

@alexfinnarn
Created August 21, 2018 17:37
Show Gist options
  • Save alexfinnarn/480d46aa9367f4e231ea9aa0fc68e142 to your computer and use it in GitHub Desktop.
Save alexfinnarn/480d46aa9367f4e231ea9aa0fc68e142 to your computer and use it in GitHub Desktop.
earlyexit helper function
# This function takes the output of the last command and exits if it failed.
earlyexit() {
CODE="$?"
if [ "${CODE}" != "0" ]; then
echo ---
echo Exiting on failure...
echo ---
exit 1
fi
echo Script succeeded.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment