~ chicken-core (chicken-5) 1d03b9998379290385123a9b5144631ebcf89df7


commit 1d03b9998379290385123a9b5144631ebcf89df7
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Sat Apr 28 11:25:42 2018 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Sat Apr 28 19:24:19 2018 +0200

    Make sure source filename argument precedes CHICKEN_OPTIONS
    
    The source filename argument is determined positionally (it must be the
    first argument), so it must be left in place when the contents of the
    CHICKEN_OPTIONS variable are added to the argument list.
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/chicken.scm b/chicken.scm
index f6dae710..f56a6ac3 100644
--- a/chicken.scm
+++ b/chicken.scm
@@ -50,9 +50,11 @@
 ;;; Prefix argument list with default options:
 
 (define compiler-arguments
-  (append
-   (string-split (or (get-environment-variable "CHICKEN_OPTIONS") ""))
-   (cdr (argv))))
+  (let ((args (cdr (argv))))
+    (append
+     (take args 1) ; Leave source filename argument first.
+     (string-split (or (get-environment-variable "CHICKEN_OPTIONS") ""))
+     (drop args 1))))
 
 
 ;;; Process command-line options:
Trap