Language: C++

#!/bin/bash

cppcode=${1}
cppoutfile=`mktemp`
exoutfile=`mktemp`
sha256saved=`cat ./sha256value`

sha256file=`sha256sum ${cppcode} | xargs | cut -f 1 -d ' '`

if [ "${sha256saved}" == "${sha256file}" ] ; then
	echo '---- compile skipped ----'
else
	echo '---- compiling... ----'
	set -e
	g++ -std=gnu++1y -O2 -o ./a.out ./${cppcode}
	set +e
        echo ${sha256file} > ./sha256value
fi

echo '---- executing... ----'
cat in.txt | ./a.out | grep ^ > ${cppoutfile}

echo '---- output ----'
cat ${cppoutfile}

echo '---- diff ----'
cat out.txt | grep ^ > ${exoutfile}
diff -u ${exoutfile} ${cppoutfile} ; ret=$?

echo '---- result ----'
if [ ${ret} -eq 0 ] ; then
	echo 'OK'
else
	echo 'NG'
fi

rm ${cppoutfile} ${exoutfile}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/bin/bash
      |  ^
a.cc:4:12: error: stray '`' in program
    4 | cppoutfile=`mktemp`
      |            ^
a.cc:4:19: error: stray '`' in program
    4 | cppoutfile=`mktemp`
      |                   ^
a.cc:5:11: error: stray '`' in program
    5 | exoutfile=`mktemp`
      |           ^
a.cc:5:18: error: stray '`' in program
    5 | exoutfile=`mktemp`
      |                  ^
a.cc:6:13: error: stray '`' in program
    6 | sha256saved=`cat ./sha256value`
      |             ^
a.cc:6:31: error: stray '`' in program
    6 | sha256saved=`cat ./sha256value`
      |                               ^
a.cc:8:12: error: stray '`' in program
    8 | sha256file=`sha256sum ${cppcode} | xargs | cut -f 1 -d ' '`
      |            ^
a.cc:8:59: error: stray '`' in program
    8 | sha256file=`sha256sum ${cppcode} | xargs | cut -f 1 -d ' '`
      |                                                           ^
a.cc:11:14: warning: multi-character literal with 25 characters exceeds 'int' size of 4 bytes
   11 |         echo '---- compile skipped ----'
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:13:14: warning: multi-character literal with 22 characters exceeds 'int' size of 4 bytes
   13 |         echo '---- compiling... ----'
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:20:6: warning: multi-character literal with 22 characters exceeds 'int' size of 4 bytes
   20 | echo '---- executing... ----'
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:23:6: warning: multi-character literal with 16 characters exceeds 'int' size of 4 bytes
   23 | echo '---- output ----'
      |      ^~~~~~~~~~~~~~~~~~
a.cc:26:6: warning: multi-character literal with 14 characters exceeds 'int' size of 4 bytes
   26 | echo '---- diff ----'
      |      ^~~~~~~~~~~~~~~~
a.cc:30:6: warning: multi-character literal with 16 characters exceeds 'int' size of 4 bytes
   30 | echo '---- result ----'
      |      ^~~~~~~~~~~~~~~~~~
a.cc:32:14: warning: multi-character character constant [-Wmultichar]
   32 |         echo 'OK'
      |              ^~~~
a.cc:34:14: warning: multi-character character constant [-Wmultichar]
   34 |         echo 'NG'
      |              ^~~~
a.cc:3:1: error: 'cppcode' does not name a type
    3 | cppcode=${1}
      | ^~~~~~~
a.cc:4:1: error: 'cppoutfile' does not name a type
    4 | cppoutfile=`mktemp`
      | ^~~~~~~~~~
a.cc:8:34: error: expected unqualified-id before '|' token
    8 | sha256file=`sha256sum ${cppcode} | xargs | cut -f 1 -d ' '`
      |                                  ^
a.cc:10:46: error: 'then' does not name a type
   10 | if [ "${sha256saved}" == "${sha256file}" ] ; then
      |                                              ^~~~
a.cc:16:9: error: 'set' does not name a type
   16 |         set +e
      |         ^~~
a.cc:17:28: error: expected unqualified-id before '>' token
   17 |         echo ${sha256file} > ./sha256value
      |                            ^
a.cc:23:1: error: 'echo' does not name a type
   23 | echo '---- output ----'
      | ^~~~
a.cc:26:1: error: 'echo' does not name a type
   26 | echo '---- diff ----'
      | ^~~~
a.cc:28:1: error: 'diff' does not name a type
   28 | diff -u ${exoutfile} ${cppoutfile} ; ret=$?
      | ^~~~
a.cc:28:22: error: '$' does not name a type
   28 | diff -u ${exoutfile} ${cppoutfile} ; ret=$?
      |                      ^
a.cc:28:38: error: 'ret' does not name a type
   28 | diff -u ${exoutfile} ${cppoutfile} ; ret=$?
      |                                      ^~~
a.cc:31:13: error: expected unqualified-id before '-' token
   31 | if [ ${ret} -eq 0 ] ; then
      |             ^
a.cc:31:23: error: 'then' does not name a type
   31 | if [ ${ret} -eq 0 ] ; then
      |                       ^~~~
a.cc:37:18: error: '$' does not name a type
   37 | rm ${cppoutfile} ${exoutfile}
      |                  ^