Isabelle_DOF/.woodpecker/check_external_file_refs

46 lines
906 B
Plaintext
Raw Permalink Normal View History

2023-02-28 01:02:23 +00:00
#!/bin/sh
2023-03-02 08:41:33 +00:00
failuremsg="Error"
failurecode=1
while [ $# -gt 0 ]
do
case "$1" in
--warning|-w)
failuremsg="Warning"
failurecode=0;;
esac
shift
done
2023-03-01 09:23:27 +00:00
DIRREGEXP="\\.\\./"
2023-03-01 09:25:10 +00:00
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 | 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
2023-03-02 08:41:33 +00:00
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