[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lisp programs as stand-alone Unix executables



In ma2s2.mathematik.uni-karlsruhe.de:/pub/lisp/clisp/contrib/clispsh.tar.z
you can find a small package which allows turning CLISP programs into
normal Unix executables. Useful for using Lisp as a "scripting language".

This package requires clisp-1995-04-04 or newer.

For example, a filter which reverses the characters in every line can be
written like this:

========================= line-reverse ======================
#!/usr/local/bin/clispsh
(defun process-file (istream ostream)
  (let ((eof "EOF"))
    (loop for line = (read-line istream nil eof)
          do (when (eq line eof) (return))
             (write-line (reverse line) ostream)
) ) )
(process-file *standard-input* *standard-output*)
=============================================================
chmod a+x line-reverse
----------------------
makes this a valid Unix executable.

The command-line arguments are passed in a variable *ARGS*, as a list of
strings. For example, a program which prints its arguments is
============= args ==============
#!/usr/local/bin/clispsh
(format t "args = ~:S~%" *args*)
=================================


Author: Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de>
Copyright policy: GNU GPL