Skip to content

Commit

Permalink
[ Fix ] Exit with correct code after failed command (#40)
Browse files Browse the repository at this point in the history
* return exit code on fail command

* remove legacy comment

---------

Co-authored-by: Gerardo Ibarra <[email protected]>
Co-authored-by: Len Woodward <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2023
1 parent 41e8003 commit d49ab1d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bin/run-hook
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash
#########################
# DO NOT EDIT THIS FILE #
#########################

# Get the hook name from the first argument
hook=$1
Expand All @@ -15,7 +12,17 @@ SCRIPTS=$($bin scripts "$hook")
# Make newlines the only separator
IFS=$'\n'

# Set the exit code to 0. If any script fails,
# this will then be set to that exit code
exit_code=0

# Run each script
for SCRIPT in $SCRIPTS; do
eval "$SCRIPT"
last_exit_code=$?
if [ $last_exit_code -ne 0 ]; then
exit_code=$last_exit_code
fi
done

exit $exit_code

0 comments on commit d49ab1d

Please sign in to comment.