cfg/bin/git-autohook
Knut Ahlers efc8bc4f3c
Throw shfmt against bash scripts
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-03-10 12:47:55 +01:00

15 lines
357 B
Bash
Executable file

#!/bin/bash
HOOKTYPE=$1
if ! [ -e Makefile ]; then
exit 0
fi
TARGETS=$(make -pRrq : 2>/dev/null |
awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' |
sort | egrep -v -e '^[^[:alnum:]]' | sed 's/:$//' | xargs)
if (echo $TARGETS | grep -q "auto-hook-${HOOKTYPE}"); then
exec make "auto-hook-${HOOKTYPE}"
fi