Question

I'm trying to run an old tool written in Lisp at the lisp REPL. I can run it every time by opening the lisp REPL, (load ...)ing the Lisp source for the tool and then running the tool command to open a file: (doStuff "filename" t). At which point it will start interactively asking me for input as it runs.

What I'd like to be able to do is to write some script which loads the tool, opens the file (which is an argument to the script (doStuff "$1" t)) and then goes into interactive mode.

As far as my research and experimentation goes, there is no way in the Lisp I am using (SBCL 1.0.57) to run a file and then go interactive. I can run input that I redirect/pipe into lisp, but the file whole process is non-interactive once I replace standard in with a redirect (correct me if I'm wrong, but that's what a pipe does as far as I understand).

What I would like is to somehow provide the Lisp REPL with several lines to run, and then have it start taking input from me. Then I can put this in a script that takes one argument (the file to use) and runs the command, prompting me for input when necessary.

Also, this does NOT need to be cross-platform or nice to look at. I'll be happy with any hacky CLI fu that works.

Was it helpful?

Solution

You use the command line option --load which is documented in 2.3.2 Toplevel Options:

--load filename

This is equivalent to --eval '(load "filename")'. The special syntax is intended to reduce quoting headaches when invoking SBCL from shell scripts.

For instance:

$ cat hello.lisp 
(print "Starting with a special startup script!")

$ sbcl --load hello.lisp 
This is SBCL 1.0.49, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.

"Starting with a special startup script!" 
* (print 'at-the-repl)

AT-THE-REPL 
AT-THE-REPL
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top