Created
February 5, 2016 05:05
-
-
Save bf4/255cf2a0402557129a83 to your computer and use it in GitHub Desktop.
Summing shell exit codes
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
result=0 | |
action() { | |
false | |
} | |
list='1 2 3' | |
for thing in $list; do | |
echo $thing | |
action | |
result+=$? | |
done | |
result+=$? | |
if [ $result -eq 0 ]; then | |
echo "SUCCESS" | |
else | |
echo "FAILURE: $result" | |
fi | |
exit $result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment