chiark / gitweb /
runlisp: Clobber *compile-print* as well.
[runlisp] / runlisp.lisp
CommitLineData
c8f068d2
MW
1;;; -*-lisp-*-
2;;;
3;;; Portable command-line tools in Lisp
4;;;
5;;; (c) 2006 Straylight/Edgeware
6;;;
7
8;;;----- Licensing notice ---------------------------------------------------
9;;;
10;;; This program is free software; you can redistribute it and/or modify
11;;; it under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 2 of the License, or
13;;; (at your option) any later version.
14;;;
15;;; This program is distributed in the hope that it will be useful,
16;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with this program; if not, write to the Free Software Foundation,
22;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24;;; Package.
25(defpackage #:runlisp
26 (:use #:common-lisp)
2eef0e68
MW
27 (:export #:*lisp-interpreter* #:*command-line-strings* #:run)
28 #+cmu (:import-from #:ext #:*command-line-strings*))
c8f068d2
MW
29(in-package #:runlisp)
30
31;;; Variables.
32(defvar *lisp-interpreter*)
2eef0e68 33(defvar *command-line-strings* nil)
c8f068d2
MW
34
35;;; Ignore shebang lines.
36(set-dispatch-macro-character #\# #\!
37 (lambda (stream bang arg)
38 (declare (ignore bang arg))
39 (read-line stream)
40 (values)))
41
42;;; Shut up, you bastard.
43#+cmu (setf ext:*gc-verbose* nil)
2eef0e68
MW
44(defun suyb ()
45 (setf *compile-verbose* nil
e711cace 46 *compile-print* nil
2eef0e68
MW
47 *load-verbose* nil
48 *load-print* nil))
49#-cmu (suyb)
c8f068d2
MW
50
51;;; Find command-line arguments and run the program.
52(defun run ()
2eef0e68 53 #+cmu (suyb)
c8f068d2
MW
54 #+cmu (let ((args lisp::lisp-command-line-list))
55 (setf *lisp-interpreter* (pop args))
56 (assert (string= (pop args) "-core"))
57 (pop args)
58 (setf *command-line-strings* args))
59 #+ecl (setf *lisp-interpreter* (ext:argv 0)
60 *command-line-strings* (loop for i from 1 below (ext:argc)
61 collect (ext:argv i)))
62 #+clisp (let ((args (coerce (ext:argv) 'list)))
63 (setf *lisp-interpreter* (car args)
64 *command-line-strings* (nthcdr 7 args)))
65 (let ((*package* (find-package "COMMON-LISP-USER"))
66 (prog (car *command-line-strings*)))
67 (handler-case
68 (progn (load prog) t)
69 (error (cond)
70 (format *error-output* "~&~A: ~A~%" (pathname-name prog) cond)
71 nil))))
72
73
74;;;----- That's all, folks --------------------------------------------------