[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme shellscripts
Date: 16 Jul 88 08:01:32 GMT
From: email@example.com (Dorai Sitaram)
A shellscript written in Scheme is like any other Scheme file, except that its
first line has to be:
runschemescript "$*" '
and its last line:
The quotes are used to delimit the Scheme code which forms the body of the
script. The script consists of a call of the Un*x command `runschemescript'
with two arguments, the first being the list of arguments to the Scheme
script, and the second the text of the Scheme code in the script. Thus, a
Scheme shellscript is a *true* schellscript, i.e., it is callable at the Un*x
command-line, though the main part of it is a piece of text which is Scheme.
The command `runschemescript' used above is a shellscript written in the usual
shell language. It is the following relatively simple piece of cshell:
If anyone can suggest further improvement I'll be glad to hear of it.
Your method, when executed, requires starting one /bin/csh to interpret
the shellscript, another /bin/csh to interpret the ``runschemescript''
shellscript, copying the scheme code into a temporary file, and invoking
the scheme implementation on that file.
I would suggest that you instead place your scheme code in a file whose
first line is ``#!/bin/scheme arg''. If your file is called foo, and
its first line is as given above, then when you execute foo, your Unix
will execute the command ``/bin/scheme arg foo''. You may omit arg, or
choose arg to be something which speeds up /bin/scheme, or tells it to
load the file whose name follows, or whatever. You will have to
convince your scheme to ignore the first line of foo, of course. This
method avoids starting up extra shells and copying files.