#!/bin/sh
#
# lminsh - little script wrapper to run LISP scripts
#
# You can use this to make LISP script files runnable from the shell.
# Just make the first line of the script file be:
#   #!/bin/sh /usr/local/bin/lminsh
# The wrapper does two things:
# 1) It skips past the first line of the LISP script so that lmin doesn't
#    get confused by the "#!".
# 2) It defines the variable "args" as a list with the string arguments to
#    the script.

sq="'"
dq='"'
script="$1"
shift
(
    echo -n "(define args $sq("
    while [ 0 -lt "$#" ] ; do
	echo "$1" | sed -e 's/"/\\"/g' -e 's/.*/"&" /' | tr -d '\n'
	shift
    done
    echo '))'
    sed 1d < "$script"
) | lmin
