;;; -*-lisp-*- ;;; ;;; Portable command-line tools in Lisp ;;; ;;; (c) 2006 Straylight/Edgeware ;;; ;;;----- Licensing notice --------------------------------------------------- ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;;; Package. (defpackage #:runlisp (:use #:common-lisp) (:export #:*lisp-interpreter* #:*command-line-strings* #:run) #+cmu (:import-from #:ext #:*command-line-strings*)) (in-package #:runlisp) ;;; Variables. (defvar *lisp-interpreter*) (defvar *command-line-strings* nil) ;;; Ignore shebang lines. (set-dispatch-macro-character #\# #\! (lambda (stream bang arg) (declare (ignore bang arg)) (read-line stream) (values))) ;;; Shut up, you bastard. #+cmu (setf ext:*gc-verbose* nil) (defun suyb () (setf *compile-verbose* nil *load-verbose* nil *load-print* nil)) #-cmu (suyb) ;;; Find command-line arguments and run the program. (defun run () #+cmu (suyb) #+cmu (let ((args lisp::lisp-command-line-list)) (setf *lisp-interpreter* (pop args)) (assert (string= (pop args) "-core")) (pop args) (setf *command-line-strings* args)) #+ecl (setf *lisp-interpreter* (ext:argv 0) *command-line-strings* (loop for i from 1 below (ext:argc) collect (ext:argv i))) #+clisp (let ((args (coerce (ext:argv) 'list))) (setf *lisp-interpreter* (car args) *command-line-strings* (nthcdr 7 args))) (let ((*package* (find-package "COMMON-LISP-USER")) (prog (car *command-line-strings*))) (handler-case (progn (load prog) t) (error (cond) (format *error-output* "~&~A: ~A~%" (pathname-name prog) cond) nil)))) ;;;----- That's all, folks --------------------------------------------------