added batch file trampoline (found by Ben Goetter)
svn: r18365
This commit is contained in:
parent
144a25ffd4
commit
d35b0b30cd
|
@ -3,14 +3,20 @@
|
||||||
scheme/cmdline
|
scheme/cmdline
|
||||||
"guide-utils.ss")
|
"guide-utils.ss")
|
||||||
|
|
||||||
@title[#:tag "scripts"]{Unix Scripts}
|
@title[#:tag "scripts"]{Scripts}
|
||||||
|
|
||||||
Under Unix and Mac OS X, a Scheme file can be turned into an
|
Scheme files can be turned into executable scripts on Unix and Mac OS
|
||||||
executable script using the shell's @as-index{@tt{#!}} convention. The
|
X. On Windows, one option is to use a compatibility layer like Cygwin,
|
||||||
first two characters of the file must be @litchar{#!}; the next
|
or write scripts as batch files.
|
||||||
character must be either a space or @litchar{/}, and the remainder of
|
|
||||||
the first line must be a command to execute the script. For some
|
@section{Unix Scripts}
|
||||||
platforms, the total length of the first line is restricted to 32
|
|
||||||
|
In a Unix environment (including Linux and Mac OS X), a Scheme file can
|
||||||
|
be turned into an executable script using the shell's @as-index{@tt{#!}}
|
||||||
|
convention. The first two characters of the file must be @litchar{#!};
|
||||||
|
the next character must be either a space or @litchar{/}, and the
|
||||||
|
remainder of the first line must be a command to execute the script. For
|
||||||
|
some platforms, the total length of the first line is restricted to 32
|
||||||
characters, and sometimes the space is required.
|
characters, and sometimes the space is required.
|
||||||
|
|
||||||
The simplest script format uses an absolute path to a @exec{mzscheme}
|
The simplest script format uses an absolute path to a @exec{mzscheme}
|
||||||
|
@ -109,3 +115,30 @@ Note that @litchar{#!} starts a line comment in Scheme, and
|
||||||
mzscheme} aborts the shell script to start @exec{mzscheme}. That way,
|
mzscheme} aborts the shell script to start @exec{mzscheme}. That way,
|
||||||
the script file turns out to be valid input to both @exec{/bin/sh} and
|
the script file turns out to be valid input to both @exec{/bin/sh} and
|
||||||
@exec{mzscheme}.
|
@exec{mzscheme}.
|
||||||
|
|
||||||
|
@section{Windows Batch Files}
|
||||||
|
|
||||||
|
A similar trick can be used to write Scheme code in Windows
|
||||||
|
@as-index{@tt{batch}} files:
|
||||||
|
|
||||||
|
@verbatim[#:indent 2]|{
|
||||||
|
; @echo off
|
||||||
|
; MzScheme.exe "%~f0" %*
|
||||||
|
; exit /b
|
||||||
|
#lang scheme/base
|
||||||
|
"Hello, world!"
|
||||||
|
}|
|
||||||
|
|
||||||
|
@;{
|
||||||
|
Original trick from Ben Goetter, who used:
|
||||||
|
|
||||||
|
; @echo off && REM -*- scheme -*-
|
||||||
|
; "%MZSCHEME%" "%~f0" %*
|
||||||
|
; exit /b
|
||||||
|
#lang scheme
|
||||||
|
...
|
||||||
|
|
||||||
|
it might be worth documenting the Emacs "-*-" convention and a way to
|
||||||
|
set environment variables -- but that would be needed in the unix part
|
||||||
|
too.
|
||||||
|
;}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user