#! /usr/bin/env zsh

ret=0;

TT=$(ls -1 | sort)

FF=$(ls -1 ${=OKFILES} | sort)
DD=$(ls -1d ${=OKDIRS} | sort)

for f in ${=FF}; do  ## remove known files from list
    test -f $f || { echo " *** no file [$f]" 1>&2; ret=1; }
    TT=${TT/$f/};
done

for d in ${=DD}; do  ## remove known dirs from list
    test -d $d || { echo " *** no dir [$d]" 1>&2; ret=1; }
    TT=${TT/$d/};
done

for t in ${=TT}; do ## what remains should not be there
        echo " *** spurious file/dir [$t]" 1>&2;
        ret=1;
done

if [ $ret != 0 ]; then
    echo " *** remove file(s) or edit OKFILES OKDIRS in makefile!" 1>&2;
fi

exit ret;
##########################
