isabelle-hacks/.woodpecker/check_external_file_refs

46 lines
928 B
Bash
Executable File

#!/bin/bash
failuremsg="Error"
failurecode=1
while [ $# -gt 0 ]
do
case "$1" in
--warning|-w)
failuremsg="Warning"
failurecode=0;;
esac
shift
done
DIRREGEXP="\\.\\./"
echo "Checking for references pointing outside of session directory:"
echo "=============================================================="
REGEXP=$DIRREGEXP
DIR=$DIRMATCH
failed=0
for i in $(seq 1 10); do
FILES=`find * -mindepth $((i-1)) -maxdepth $i -type f -not -name "*.diff" | xargs`
if [ -n "$FILES" ]; then
grep -s ${REGEXP} ${FILES}
exit=$?
if [ "$exit" -eq 0 ] ; then
failed=1
fi
fi
REGEXP="${DIRREGEXP}${REGEXP}"
done
if [ "$failed" -ne 0 ] ; then
echo "$failuremsg: Forbidden reference to files outside of their session directory!"
exit $failurecode
fi
echo " * Success: No relative references to files outside of their session directory found."
exit 0