#! /bin/bash
#------------------------------------------------------------------------------
#$Author: saulius $
#$Date: 2017-12-14 21:08:48 +0000 (Thu, 14 Dec 2017) $
#$Revision: 3994 $
#$URL: file:///home/saulius/svn-repositories/paskaitos/VU/software/assignment-evaluation/trunk/scripts/do-check-BPKM-3rd--comments $
#------------------------------------------------------------------------------
#*
# Check that the project executable files have comments.
#**

set -ue
## set -x

DIRECTORY="$1"

ID='$Id: do-check-BPKM-3rd--comments 3994 2017-12-14 21:08:48Z saulius $'

cd "${DIRECTORY}"

COUNT=0

find . \
     -name bibliophile -prune -o \
     -name '*~' -prune -o \
     -name .svn -prune -o \
     -name .git -prune -o \
     -type f -perm /111 \
     -print \
| while read FILE
do
    if head -1 "${FILE}" | grep -q '^#!' > /dev/null 2>&1
    then
        if [ $(grep -P '^\s*#' "${FILE}" | wc -l) -le 3 ]
        then
    
cat <<EOF
-- [AUTO;INTERFACE;$(echo $ID | sed 's/\$//g')]

   Jūsų projekto programoje '${FILE}' reikia daugiau komentarų
   (-5 balai);

EOF

        fi
    fi
done;

## echo $0: COUNT=$COUNT >&2

