Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
pakcs
Commits
9d3dcf15
Commit
9d3dcf15
authored
Jul 10, 2015
by
Michael Hanus
Browse files
Script corrected
parent
fb508765
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/runcurry.sh
View file @
9d3dcf15
...
...
@@ -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
PRO
G
=
$1
AR
G
=
$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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment