chiark / gitweb /
src/optparse.lisp: Simplify `set-command-line-arguments'.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 17 Aug 2015 16:44:57 +0000 (17:44 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 17 Aug 2015 16:48:14 +0000 (17:48 +0100)
If we depend on `cl-launch' and assume that we're always started through
it then we don't need to do such complicated things to put together the
command line.

It's not all happy bunnies, unfortunately, because we have to mess with
system-specific details to discover the program name from a dumped
executable image.

src/optparse.lisp
src/sod-frontend.asd

index fc46ba457f3e47f12059e50839deb7f1ade15e7f..70bb0122cc335dd5dd22b8f65af2551498e3c3a1 100644 (file)
@@ -24,7 +24,7 @@
 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 (cl:defpackage #:optparse
-  (:use #:common-lisp #:sod-utilities))
+  (:use #:common-lisp #:cl-launch #:sod-utilities))
 
 (cl:in-package #:optparse)
 
@@ -62,21 +62,13 @@ (defun set-command-line-arguments ()
    Set `*command-line*' and `*program-name*'."
 
   (setf *command-line*
-       (or (when (member :cl-launch *features*)
-             (let* ((cllpkg (find-package :cl-launch))
-                    (name (funcall (intern "GETENV" cllpkg)
-                                   "CL_LAUNCH_FILE"))
-                    (args (symbol-value (intern "*ARGUMENTS*" cllpkg))))
-               (if name
-                   (cons name args)
-                   args)))
-           #+sbcl sb-ext:*posix-argv*
-           #+cmu ext:*command-line-strings*
-           #+clisp (loop with argv = (ext:argv)
-                         for i from 7 below (length argv)
-                         collect (aref argv i))
-           #+ecl (loop from i below (ext:argc) collect (ext:argv i))
-           '("<unknown-script>"))
+       (cons (or (getenv "CL_LAUNCH_FILE")
+                 #+sbcl (car sb-ext:*posix-argv*)
+                 #+cmu (car ext:*command-line-strings*)
+                 #+clisp (aref (ext:argv) 0)
+                 #+ecl (ext:argv 0)
+                 #-(or sbcl cmu clisp ecl) "sod")
+             *arguments*)
 
        *program-name* (pathname-name (car *command-line*))))
 
index 348c4be4b944fd5ed04dae7d57a8747535b0118e..6ba17cdfbf22fd1d7023576dfe150d047955f81a 100644 (file)
@@ -49,7 +49,7 @@
    a separate system because it has additional dependencies and
    Lisp-system-specific code."
 
-  :depends-on ("sod")
+  :depends-on ("cl-launch" "sod")
 
   :components
   ((:file "optparse")