fix double-loading of script in -ds case
authorAndy Wingo <wingo@pobox.com>
Thu, 28 Apr 2011 19:43:01 +0000 (21:43 +0200)
committerAndy Wingo <wingo@pobox.com>
Thu, 28 Apr 2011 19:43:01 +0000 (21:43 +0200)
* module/ice-9/command-line.scm (compile-shell-switches): In the -ds
  case, we were erroneously loading the script twice.  Fix that.

module/ice-9/command-line.scm

index a34c9a6..670382f 100644 (file)
@@ -197,26 +197,28 @@ If FILE begins with `-' the -s switch is mandatory.
               (args (cdr args)))
           (cond
            ((not (string-prefix? "-" arg)) ; foo
-            ;; If we specified the -ds option, do_script points to the
-            ;; cdr of an expression like (load #f) we replace the car
-            ;; (i.e., the #f) with the script name.
-            (if (pair? do-script)
-                (set-car! do-script arg))
+            ;; If we specified the -ds option, do-script is the cdr of
+            ;; an expression like (load #f).  We replace the car (i.e.,
+            ;; the #f) with the script name.
             (set! arg0 arg)
             (set! interactive? #f)
-            (finish args
-                    (cons `(load ,arg) out)))
+            (if (pair? do-script)
+                (begin
+                  (set-car! do-script arg0)
+                  (finish args out))
+                (finish args (cons `(load ,arg0) out))))
 
            ((string=? arg "-s")         ; foo
             (if (null? args)
                 (error "missing argument to `-s' switch"))
             (set! arg0 (car args))
-            (if (pair? do-script)
-                (set-car! do-script arg0))
             (set! interactive? #f)
-            (finish (cdr args)
-                    (cons `(load ,arg0) out)))
-
+            (if (pair? do-script)
+                (begin
+                  (set-car! do-script arg0)
+                  (finish (cdr args) out))
+                (finish (cdr args) (cons `(load ,arg0) out))))
+           
            ((string=? arg "-c")         ; evaluate expr
             (if (null? args)
                 (error "missing argument to `-c' switch"))