From d4d20af163a97f2af069b2c12c1672b08835d1c2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 21 Jul 2022 08:13:18 -0700 Subject: compile-file: revise hash bang treatment. * stdlib/compiler.tl (translate-hash-bang): New function. (compile-file-conditionally): Use translate-hash-bang to treat hash bang line. * txr.1: Revised hash bang treatment by file compiler documented. --- stdlib/compiler.tl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'stdlib') diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index c7ac6009..b82f85a2 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -2316,6 +2316,14 @@ (if (eql sti.gid sto.gid) sgid))))) (chmod out-stream mode))))) +(defun translate-hash-bang (hbline) + (flow hbline + (spl " ") + (subst "--lisp" "--compiled") + (mapcar [iffi (op ends-with "txrlisp") + (opip (trim-right "lisp") (join @1 "vm"))]) + (ap join-with " "))) + (defun compile-file-conditionally (in-path out-path test-fn) (whenlet ((success nil) (perms nil) @@ -2338,11 +2346,9 @@ (with-compilation-unit (iflet ((line (get-line in-stream)) ((starts-with "#!" line))) - (progn - (set line `@line `) - (upd line (regsub #/--lisp[^\-]/ (ret `--compiled@[@1 -1]`))) - (put-line (butlast line) out-stream) - (set perms t)) + (let ((cline (translate-hash-bang line))) + (set perms t) + (put-line cline out-stream)) (seek-stream in-stream 0 :from-start)) (labels ((compile-form (unex-form) (let* ((form (macroexpand unex-form)) -- cgit v1.2.3