#!/bin/bash

#requires not make

BOUT_TOP=../../..
error=

paths="src include examples tests"


# Check that exceptions are caught by reference
for path in $paths
do
    catch_errors=$(grep catch[^\(]*\([^\(]*Bout $BOUT_TOP/$path --include=*xx -r|grep -v '&')
    ex=$?
    if test $ex -eq 0
    then
        error=yes
        echo "Found catch by value - not by reference:"
        echo "$catch_errors"
    fi
done


# Return
if test $error
then
    echo "-> Errors listed above"
    exit 1
else
    echo "No Errors detected"
    exit 0
fi
