strip #! from start of programs

svn: r1376

original commit: c0476d4addfa1cd58cd85cad32b89bb9fd93eae4
This commit is contained in:
Matthew Flatt 2005-11-22 22:34:35 +00:00
parent dd3c8a4365
commit 8fb4d8327e
2 changed files with 28 additions and 19 deletions

View File

@ -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")

View File

@ -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))