#!/bin/bash
###set -e

trap "exit" INT

files=${1:-assignment*}


for sd in $files; do
    echo -e "\n"
    echo $sd/cw5/cw05.sc
    if test -f $sd/cw5/cw05.sc; then
	echo -e " FILE EXITS\n"
	cd $sd/cw5
	if test -f ../DONE5.txt; then
	    echo "DONE5.txt file exists."
	    cat ../DONE5.txt
	else
	    touch .
	    cp ../../../../cw5_marking/cw5_test.sh .
	    cp ../../../../cw5_marking/c.sc .
	    cp ../../../../cw5_marking/c{1,2,3,4,5,6}.sc .
	    cp ../../../../cw5_marking/c{1,2,3}_add.sc .
	    cp ../../../../cw5_marking/*.fun .
	    cp ../../../../cw5_marking/mand.out .
	    #rm -rf /Users/cu/.ammonite/cache/3.0.0-M2/*
	    ./cw5_test.sh output
	    rm cw5_test.sh
	    rm c.sc
	    rm c{1,2,3,4,5,6}.sc
	    rm c{1,2,3}_add.sc
	    rm *.fun
	    #rm mand.out
	fi
	cd ..
	cd ..
    else
	echo -e " FILE cw05.sc DOES NOT EXITS\n"
	echo -e " FILE cw05.sc DOES NOT EXITS\n 0.0" > $sd/DONE5.txt
    fi
done


