From 8fb4d8327e59bc813e67cfaa9b811388d705afb1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 22 Nov 2005 22:34:35 +0000 Subject: [PATCH] strip #! from start of programs svn: r1376 original commit: c0476d4addfa1cd58cd85cad32b89bb9fd93eae4 --- collects/mzlib/file.ss | 36 ++++++++++++++++++------------------ collects/mzlib/port.ss | 11 ++++++++++- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/collects/mzlib/file.ss b/collects/mzlib/file.ss index 786cdd2..ea24651 100644 --- a/collects/mzlib/file.ss +++ b/collects/mzlib/file.ss @@ -1,26 +1,26 @@ (module file mzscheme (provide find-relative-path - explode-path - normalize-path - build-absolute-path - build-relative-path - filename-extension - file-name-from-path - path-only - delete-directory/files - copy-directory/files - make-directory* - make-temporary-file - find-library + explode-path + normalize-path + build-absolute-path + build-relative-path + filename-extension + file-name-from-path + path-only + delete-directory/files + copy-directory/files + make-directory* + make-temporary-file + find-library - get-preference - put-preferences + get-preference + put-preferences - call-with-input-file* - call-with-output-file* + call-with-input-file* + call-with-output-file* - fold-files - find-files) + fold-files + find-files) (require "list.ss" "etc.ss") diff --git a/collects/mzlib/port.ss b/collects/mzlib/port.ss index 1a928c3..bc072e2 100644 --- a/collects/mzlib/port.ss +++ b/collects/mzlib/port.ss @@ -19,7 +19,8 @@ convert-stream make-limited-input-port reencode-input-port - reencode-output-port) + reencode-output-port + strip-shell-command-start) (define (exact-non-negative-integer? i) (and (number? i) (exact? i) (integer? i) (i . >= . 0))) @@ -77,6 +78,14 @@ ;; ---------------------------------------- + (define (strip-shell-command-start in) + (when (regexp-match-peek #rx#"^#![^\r\n]*" in) + (let loop ([s (read-line in)]) + (when (regexp-match #rx#"\\\\$" s) + (loop (read-line in)))))) + + ;; ---------------------------------------- + (define (copy-port src dest . dests) (unless (input-port? src) (raise-type-error 'copy-port "input-port" src))