#!/usr/bin/env bash
# CHECK -- gate for the 2026-10-29 check-in signee census.
#
# `bash CHECK` runs the grader, and so does `./CHECK`. The previous revision was
# a Python file under a `bash CHECK` line, so it exited 2 on `import: command not
# defined` without grading anything; and its legs read `git ls-files`, which is
# the live index, so every check-in that landed after 2026-10-29 reddened a
# dated artifact for no reason. The scope is now the pinned revision beside this
# file, and the grade is in grade.py so the documented invocation is the one that
# runs.
#
# 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" "$@"
