Changeset 13226 for trunk/abcl/src/org


Ignore:
Timestamp:
02/20/11 20:02:08 (10 years ago)
Author:
vvoutilainen
Message:

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 --

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Interpreter.java

    r13144 r13226  
    5656    private static boolean noinform = false;
    5757    private static boolean help = false;
     58    private static boolean doubledash = false;
    5859
    5960    public static synchronized Interpreter getInstance()
     
    105106        if (!noinit)
    106107            processInitializationFile();
     108        doubledash = false;
    107109        if (args != null)
    108110            postprocessCommandLineArguments(args);
     
    239241            for (int i = 0; i < args.length; ++i) {
    240242                String arg = args[i];
    241                 if (arg.equals("--noinit")) {
     243                if (doubledash) {
     244                    arglist = new Cons(args[i], arglist);
     245                } else if (arg.equals("--")) {
     246                    doubledash = true;
     247                } else if (arg.equals("--noinit")) {
    242248                    noinit = true;
    243249                } else if (arg.equals("--nosystem")) {
     
    281287            for (int i = 0; i < args.length; ++i) {
    282288                String arg = args[i];
    283                 if (arg.equals("--eval")) {
     289                if (doubledash) {
     290                    continue;
     291                } else if (arg.equals("--")) {
     292                    doubledash = true;
     293                } else if (arg.equals("--eval")) {
    284294                    if (i + 1 < args.length) {
    285295                        try {
Note: See TracChangeset for help on using the changeset viewer.