#! /bin/bash
#------------------------------------------------------------------------------
#$Author: saulius $
#$Date: 2017-11-23 14:18:17 +0000 (Thu, 23 Nov 2017) $
#$Revision: 3870 $
#$URL: file:///home/saulius/svn-repositories/paskaitos/VU/software/assignment-evaluation/trunk/scripts/do-check--data-not-executable $
#------------------------------------------------------------------------------
#*
# Check that not all files are executable.
#**

set -ue
## set -x

DIRECTORY="$1"

ID='$Id: do-check--data-not-executable 3870 2017-11-23 14:18:17Z saulius $'

cd "${DIRECTORY}"

EXCUTABLE_COUNT=$(find . \
                       -name .svn -prune -o \
                       -name .git -prune -o \
                       -type f -executable \
                       -print | wc -l)

ALL_FILE_COUNT=$(find . \
                      -name .svn -prune -o \
                      -name .git -prune -o \
                      -type f \
                      -print | wc -l)

## echo $0: EXECUTABLE_COUNT=$EXCUTABLE_COUNT >&2
## echo $0: ALL_FILE__COUNT=$ALL_FILE_COUNT >&2

if [ $ALL_FILE_COUNT -gt 1 -a $ALL_FILE_COUNT -eq $EXCUTABLE_COUNT ]
then
    
cat <<EOF
-- [AUTO;INTERFACE;$(echo $ID | sed 's/\$//g')]

   Jūsų projekto visi failai yra vykdomi. Duomenų failai (Makefile,
   testų įvestys ir etaloniniai rezultatai) neturi būti vykdomi.
   Pataisykite (-10 balų);

EOF

fi
