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

trap "exit" INT

files=${1:-assignment*}


for sd in $files; do
    echo -e "\n"
    echo $sd/cw3/cw03.sc
    if test -f $sd/cw3/cw03.sc; then
	#echo -e " FILE EXITS\n"
	cd $sd/cw3
	if test -f ../DONE3.txt; then
	    echo "DONE3.txt file exists."
	    cat ../DONE3.txt
	else
	    touch .
	    cp ../../../../cw3_marking/cw3_test.sh .
	    cp ../../../../cw3_marking/c.sc .
	    cp ../../../../cw3_marking/c{3,4,5}.sc .
            cp ../../../../cw3_marking/c{3,4}_add.sc .
	    cp ../../../../cw3_marking/c4_pre.sc . 
	    cp ../../../../cw3_marking/*.while . 
	    #rm -rf /Users/cu/.ammonite/cache/3.0.0-M2/*
	    ./cw3_test.sh output
	    rm cw3_test.sh
	    rm c.sc
	    rm c{3,4,5}.sc
	    rm c{3,4}_add.sc
	    rm c4_pre.sc
	    rm *.while
	fi
	cd ..
	cd ..
    else
	echo -e " FILE cw03.sc DOES NOT EXITS\n"
	echo -e " FILE cw03.sc DOES NOT EXITS\n 0.0" > $sd/DONE3.txt
    fi
done


