diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-07-11 22:11:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-07-11 22:11:28 -0700 |
commit | f71aad515d95107da81a3f70d080e75675ce87e2 (patch) | |
tree | 6cc0ea3247b275b2de9b22cf55b385d4847b9083 | |
parent | 4ffee7148db812a67b9752e710bad54a7dc9dabb (diff) | |
download | txr-f71aad515d95107da81a3f70d080e75675ce87e2.tar.gz txr-f71aad515d95107da81a3f70d080e75675ce87e2.tar.bz2 txr-f71aad515d95107da81a3f70d080e75675ce87e2.zip |
compile-file: support hash bang.
* share/txr/stdlib/compiler.tl (usr:compile-file): Check for a
hash bang line in the source file. If so, propagate it
to the compiled file.
* txr.1: Documented existing support for hash bang in .tlo
files, and the translation of hash bang from .tl to .tlo.
-rw-r--r-- | share/txr/stdlib/compiler.tl | 4 | ||||
-rw-r--r-- | txr.1 | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 56db42b2..5b194263 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -1595,6 +1595,10 @@ (with-resources ((in-stream (car streams) (close-stream in-stream)) (out-stream (cadr streams) (close-stream out-stream)) (out (new list-builder))) + (iflet ((line (get-line in-stream)) + ((starts-with "#!" line))) + (put-line line out-stream) + (seek-stream in-stream 0 :from-start)) (labels ((compile-form (form) (unless (atom form) (caseq (car form) @@ -62306,6 +62306,17 @@ special variable has no influence on this. Circular structures in compiled literals are preserved; on loading, similar circular structures are reproduced. +.SS* Treatment of The Hash Bang Line + +When a source file begins with the +.code #! +("hash-bang") character sequence, the file compiler propagates that +line to the compiled file, verbatim. + +\*(TX supports the hash bang mechanism in compiled +.code .tlo +files, thereby allowing compiled scripts to be executable. + .coNP Function @ compile-toplevel .synb .mets (compile-toplevel < form << expanded-p ) |