#! /bin/sh
# @TEST-EXEC: /bin/sh %INPUT
# @TEST-EXEC-FAIL: test -s .stderr
#
# Checks that the main sources files have our one-line license header in place.

if [ -n "${DIST}" ]; then
    cd "${DIST}"
else
    cd $(dirname $0)/../..
fi

git ls-files \
    | grep -E -v '^(tests|doc)/' \
    | grep -E -v '3rdparty/' \
    | grep -E -v '^\.$' \
    | grep -E '\.(h|c|cc|py|sh|api|ll|yy|h.in|cc.in|c.in|txt|evt|hilti|spicy)$' \
    | while read i; do
        grep -q "Copyright.*Zeek" $i || echo "No appropriate copyright header in '$i'" >&2
done
