#!/bin/bash
#
# We fail CI if the word "F I X M E" is detedcted, as a whole word,
# in any case.  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 -i '\bfixme\b'
check1 git --no-pager grep '\bXXXX*\b'

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