[armedbear-cvs] r13226 - trunk/abcl/src/org/armedbear/lisp

Ville Voutilainen vvoutilainen at common-lisp.net
Sun Feb 20 20:02:10 UTC 2011


Author: vvoutilainen
Date: Sun Feb 20 15:02:08 2011
New Revision: 13226

Log:
Fix ticket #128. This patch enables the use of -- as a parameter,
and using such a parameter will stop abcl from further processing
the parameters given. Example used for testing:

(loop
 for item in *command-line-argument-list*
 do (format t "got arg ~a~%" item))

With that snippet saved into cmdlinetest.lisp, we can do

./abcl --batch --eval '(load "cmdlinetest.lisp")' -- hops hups jee jee --eval '(format t "hah~%")' -- -- --

and have it print

Armed Bear Common Lisp 0.25.0-dev-svn-13225M
Java 1.6.0_22 Sun Microsystems Inc.
Java HotSpot(TM) Server VM
Low-level initialization completed in 0.626 seconds.
Startup completed in 1.778 seconds.
got arg hops
got arg hups
got arg jee
got arg jee
got arg --eval
got arg (format t "hah~%")
got arg --
got arg --
got arg --




Modified:
   trunk/abcl/src/org/armedbear/lisp/Interpreter.java

Modified: trunk/abcl/src/org/armedbear/lisp/Interpreter.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Interpreter.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Interpreter.java	Sun Feb 20 15:02:08 2011
@@ -55,6 +55,7 @@
     private static boolean nosystem = false;
     private static boolean noinform = false;
     private static boolean help = false;
+    private static boolean doubledash = false;
 
     public static synchronized Interpreter getInstance()
     {
@@ -104,6 +105,7 @@
             initializeSystem();
         if (!noinit)
             processInitializationFile();
+        doubledash = false;
         if (args != null)
             postprocessCommandLineArguments(args);
 
@@ -238,7 +240,11 @@
         if (args != null) {
             for (int i = 0; i < args.length; ++i) {
                 String arg = args[i];
-                if (arg.equals("--noinit")) {
+                if (doubledash) {
+                    arglist = new Cons(args[i], arglist);
+                } else if (arg.equals("--")) {
+                    doubledash = true;
+                } else if (arg.equals("--noinit")) {
                     noinit = true;
                 } else if (arg.equals("--nosystem")) {
                     nosystem = true;
@@ -280,7 +286,11 @@
         if (args != null) {
             for (int i = 0; i < args.length; ++i) {
                 String arg = args[i];
-                if (arg.equals("--eval")) {
+                if (doubledash) {
+                    continue;
+                } else if (arg.equals("--")) {
+                    doubledash = true;
+                } else if (arg.equals("--eval")) {
                     if (i + 1 < args.length) {
                         try {
                             evaluate(args[i + 1]);




More information about the armedbear-cvs mailing list