Skip to content

Instantly share code, notes, and snippets.

@bf4
Created February 5, 2016 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bf4/255cf2a0402557129a83 to your computer and use it in GitHub Desktop.
Save bf4/255cf2a0402557129a83 to your computer and use it in GitHub Desktop.
Summing shell exit codes
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