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

trap "exit" INT

files=${1:-assignment*}


for sd in $files; do
    echo -e "\n"
    echo $sd/cw4/cw04.sc
    if test -f $sd/cw4/cw04.sc; then
	echo -e " FILE EXITS\n"
	cd $sd/cw4
	if test -f ../DONE4.txt; then
	    echo "DONE4.txt file exists."
	    cat ../DONE4.txt
	else
	    touch .
	    cp ../../../../cw4_marking/cw4_test.sh .
	    cp ../../../../cw4_marking/c.sc .
	    cp ../../../../cw4_marking/c{1,2,3,4}.sc .
	    cp ../../../../cw4_marking/c1_add.sc .
	    cp ../../../../cw4_marking/*.while .
	    #rm -rf /Users/cu/.ammonite/cache/3.0.0-M2/*
	    ./cw4_test.sh output
	    rm cw4_test.sh
	    rm c.sc
	    rm c{1,2,3,4}.sc
	    rm c1_add.sc
	    rm *.while
	fi
	cd ..
	cd ..
    else
	echo -e " FILE cw04.sc DOES NOT EXITS\n"
	echo -e " FILE cw04.sc DOES NOT EXITS\n 0.0" > $sd/DONE4.txt
    fi
done


