#!/bin/bash
#
# We fail CI if the word "F E R R E T" is detedcted, as a whole word,
# in capitals.  The word is not matched if there are word-characters
# abutted to it.

set -e
set -o pipefail

rcs=' '
check1 () {
    set +e
    "$@"
    rcs+="$? "
    set -e
}
check1 git --no-pager grep -P '\b[F]ERRET\b'

case "$rcs" in
    " 1 ")
	exit 0
	;;
    *" 0 "*)
	echo >&2 'Found FERRETs - RC TODS - in the codebase!'
	exit 1
	;;
    *)
	echo >&2 'git grep failed!'
	exit 16
	;;
esac
