Created
October 5, 2017 22:55
-
-
Save kdridi/518bbd1334030a6ac8c2b29c909bb5c2 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit
This file contains hidden or 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
#!/usr/bin/env bash | |
################################################################################ | |
echo -n "Object files: " | |
################################################################################ | |
if test -f *.o; then | |
echo "KO" | |
exit 84 | |
else | |
echo "OK" | |
fi | |
################################################################################ | |
echo -n "Compilation: " | |
################################################################################ | |
gcc -W -Wall -Wextra -Werror -c *.c | |
if [[ $? == 0 ]]; then | |
echo "OK" | |
else | |
echo "KO" | |
exit 84 | |
fi | |
################################################################################ | |
echo -n "Function main doesn't exist: " | |
################################################################################ | |
if [[ 0 -eq $(nm *.o | egrep ' T _main$' | wc -l) ]]; then | |
echo "OK" | |
else | |
echo "KO" | |
rm -rf *.o | |
exit 84 | |
fi | |
################################################################################ | |
echo -n "Function my_putchar doesn't exist: " | |
################################################################################ | |
if [[ 0 -eq $(nm *.o | egrep ' T _my_putchar$' | wc -l) ]]; then | |
echo "OK" | |
else | |
echo "KO" | |
rm -rf *.o | |
exit 84 | |
fi | |
rm -rf *.o | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment