#!/bin/bash

# Copyright 2020-2021 The Khronos Group, Inc.
# SPDX-License-Identifier: Apache-2.0

# scripts/ci/check_undefined
# Check for non-tagged 'undefined' in spec sources.
# Skip appendices/VK* files, which are non-normative.
# Ideally we would skip NOTES too, but that would require parsing.

undefined=/tmp/undefined
ls chapters/*txt chapters/*/*txt appendices/[A-UW-Za-z]*txt | \
    xargs egrep -E '(^|[[:space:]])undefined($|[^:])' > $undefined
if test `cat $undefined | wc -l` -gt 0 ; then
    echo "*** Found un-tagged uses of 'undefined'"
    cat $undefined
    rm $undefined
    exit 1
else
    rm $undefined
    exit 0
fi
