#!/bin/bash
#
# Wrapper script for Leo2 to take TPTP input from the console
#
# Nik Sultana, Sept 2012, Free University Berlin

if [ -z "${LEO2}" ]; then
  echo "Need to set \$LEO2 to Leo-II's 'trunk' path"
  exit 1
fi

LEO2_ARGS=$1

#Naive generation of tmp filename
TMPFILE="/tmp/askleo_$$_${RANDOM}"
if [ -e "${TMPFILE}" ]; then
  echo "Randomly-generated tmp filename (${TMPFILE}) already exists -- please rerun command"
  exit 1
fi

trap "rm -f ${TMPFILE}; exit" EXIT

cat - > ${TMPFILE}
${LEO2}/bin/leo ${LEO2_ARGS} ${TMPFILE}
