-
-
Save Kerruba/4d2e4c3d584c45b962d949ed7a7e47e9 to your computer and use it in GitHub Desktop.
Try-Catch Behavior in Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -- | |
# Note -- will make script continue despite errors | |
echo "Some command that fails" | |
RETURN_CODE=$?; #capture error code here (if any) | |
echo "Cleanup before script is allowed to fail" | |
[[ $RETURN_CODE -ne 0 ]] && exit $RETURN_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment