#!/usr/bin/env bash
# CHECK -- gate for the 2026-10-28 check-in census.
#
# `bash CHECK` runs the grader, and so does `./CHECK`. The grade itself lives in
# grade.py because this artifact publishes character counts of a UTF-8 slice and
# awk measures bytes; this wrapper exists so the documented invocation is the one
# that actually runs. The previous revision was a Python file under a
# `bash CHECK` line, so it exited 2 on `import: command not found` without
# grading anything, and its own leg ran the extractor over the live directory and
# rewrote the committed tables in place.
#
# Exit codes: 0 every leg passed; 1 a fault; 2 cannot grade (no python3 or git).
set -u

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if ! command -v python3 >/dev/null 2>&1; then
  printf 'CANNOT GRADE: python3 not on PATH\n' >&2
  exit 2
fi
if ! command -v git >/dev/null 2>&1; then
  printf 'CANNOT GRADE: git not on PATH\n' >&2
  exit 2
fi

exec python3 "$HERE/grade.py" "$@"
