#!/bin/bash
#
# Compile with P5 using FreePascal
#
# Execute with:
#
# p5 <file>
#
# Where <file> is the name of the source file without
# extention. The Pascal file is compiled and run.
# Any compiler errors are output to the screen.
# Input and output to and from the running program
# are from the console.
# The intermediate code is placed in <file>.p5.
#

if [ -z "\$1" ]
then

   echo "*** Error: Missing parameter"
   exit 1

fi

if [ ! -f \$1.pas ]
then

   echo "*** Error: Missing \$1.pas file"
   exit 1

fi

echo Compiling and running \$1
echo
pcom < \$1.pas > \$1.p5
pint < \$1.p5
