Commit 9d3dcf15 authored by Michael Hanus 's avatar Michael Hanus
Browse files

Script corrected

parent fb508765
......@@ -10,7 +10,7 @@ show_usage () {
echo "Usage:"
echo
echo "As a shell command:"
echo "> runcurry [Curry system options] <Curry program> <run-time arguments>"
echo "> runcurry [Curry system options] <Curry program name> <run-time arguments>"
echo
echo "As a shell script: start script with"
echo "#!/usr/bin/env runcurry"
......@@ -21,7 +21,6 @@ show_usage () {
echo "...type your Curry program until end-of-file..."
}
# define a new Curry file name:
NEWMOD=RUNCURRY$$
while [ -f $NEWMOD.curry ] ; do
......@@ -29,49 +28,40 @@ while [ -f $NEWMOD.curry ] ; do
done
NEWPROG=$NEWMOD.curry
CURRYARGS=
PROG=
DELPROG=no
if [ $# = 0 ] ; then
# no arguments provided, use remaining input as program:
PROG=$NEWPROG
cat > $PROG
DELPROG=yes
elif [ $# = 1 ] ; then
while [ $# -gt 0 -a -z "$PROG" ] ; do
if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "-?" ] ; then
show_usage ; exit
fi
PROG=$1
ARG=$1
shift
ARGwolcurry=`expr $ARG : '\(.*\)\.lcurry'`
ARGwocurry=`expr $ARG : '\(.*\)\.curry'`
# check whether runcurry is called in script mode, i.e., the argument
# is not a Curry program but an existing file:
PROGwolcurry=`expr $PROG : '\(.*\)\.lcurry'`
PROGwocurry=`expr $PROG : '\(.*\)\.curry'`
if [ -z "$PROGwolcurry" -a -z "$PROGwocurry" -a -f $PROG ] ; then
# store PROG in a Curry program, but remove lines starting with '#':
sed 's|^#.*$||' < $PROG > $NEWPROG
if [ "$ARGwolcurry" != "" -o "$ARGwocurry" != "" ] ; then
# argument is a Curry program:
PROG=$ARG
elif [ -x $ARG ] ; then
# argument is not a Curry file but is executable, hence a script:
# store ARG in a Curry program, but remove lines starting with '#':
sed 's|^#.*$||' < $ARG > $NEWPROG
DELPROG=yes
PROG=$NEWPROG
else
# argument is a Curry system argument:
CURRYSYSARGS="$CURRYSYSARGS $ARG"
fi
else
# split arguments into system arguments and Curry program:
CURRYSYSARGS=
PROG=
while [ -z "$PROG" ] ; do
# check whether argument is the name of a Curry program:
PROGwolcurry=`expr $1 : '\(.*\)\.lcurry'`
PROGwocurry=`expr $1 : '\(.*\)\.curry'`
if [ -z "$PROGwolcurry" -a -z "$PROGwocurry" ] ; then
CURRYSYSARGS="$CURRYSYSARGS $1"
else
PROG=$1
fi
shift
if [ $# = 0 ] ; then
echo "ERROR: No Curry program name provided as argument!" >&2
exit 1
fi
done
fi
done
if [ -z "$PROG" ] ; then
# no program argument provided, use remaining input as program:
PROG=$NEWPROG
cat > $PROG
DELPROG=yes
fi
$PAKCSHOME/bin/curry :set v0 :set parser -Wnone $CURRYSYSARGS :load "$PROG" :set args ${1+"$@"} :eval main :quit
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment