#!/bin/bash
#Author Martin Prudek

if [ $# -eq 0 ]; then
	cd benchmark_sets;
	matlab -nodisplay -r "example_CAN_CTU(); exit;";
else
	if [ "`cat "$1" | grep -o "MTW" | awk '{print $1}' | head -1`" = "MTW" ]; then
		echo "Using MathWorks ert. Need to start matlab with a display. Continue? [y/n]";
		read answer
		if [ $answer = "y" ]; then
			cd benchmark_sets;
			mscript=`echo $1 | sed 's:.*/::' | awk -F . '{print $1}'`;
			matlab -r "${mscript}(); exit;";
		else
			exit 1;
		fi
	else
		cd benchmark_sets;
		mscript=`echo $1 | sed 's:.*/::' | awk -F . '{print $1}'`;
		matlab -nodisplay -r "${mscript}(); exit;";
	fi
fi
