#!/bin/bash if [ $# -ne 2 ] then echo "usage $0 INPUT NUM"; exit 1; fi; if ! [ -r $1 ]; then echo "$0: first parameter must be readable file"; exit 1; fi; if [[ $2 != [0-9] ]] && [[ $2 != [0-9][0-9] ]]; then echo "$0: second parameter must be a natural number < 100"; exit 1; fi; if [ -e fib-test-output ]; then echo "$0: file \"fib-test-output\" already exists"; exit 1; fi; out=fib-test-output; echo '( /* beginning of fib code */' > $out; cat $1 >> $out; echo '/* end of fib code */ )' >> $out; echo '' >> $out; echo -n '(lambda s. lambda z. ' >> $out; if [ $2 -eq 0 ]; then echo -n 'z' >> $out; else typeset -i n=$2; while [ $n -gt 1 ]; do echo -n 's(' >> $out; n=$n-1; done; echo -n 's z' >> $out; n=$2; while [ $n -gt 1 ]; do echo -n ')' >> $out; n=$n-1; done; fi; echo ') /*'" $2 "'*/' >> $out; echo '(lambda x. lambda y. y x)' >> $out; echo '(lambda x. x);' >> $out;