Next: , Previous: , Up: Scripting   [Contents][Index]

3.13.2 MS-DOS Compatible Scripts

It turns out that we can create scheme-scripts which run both under unix and MS-DOS. To implement this, I have written the MS-DOS programs: #!.bat and !#.exe, which are available from:

With these two programs installed in a PATH directory, we have the following syntax for <program>.BAT files.

file: #! interpreter \ %0 %*

The first two characters of the Scheme-Script are ‘#!’. The interpreter can be either a unix style program path (using ‘/’ between filename components) or a DOS program name or path. The rest of the first line of the Scheme-Script should be literally ‘\ %0 %*, as shown.

If interpreter has ‘/’ in it, interpreter is converted to a DOS style filename (‘/’ ⇒ ‘\’).

In looking for an executable named interpreter, #! first checks this (converted) filename; if interpreter doesn’t exist, it then tries to find a program named like the string starting after the last ‘\’ (or ‘/’) in interpreter. When searching for executables, #! tries all directories named by environment variable PATH.

Once the interpreter executable path is found, arguments are processed in the manner of scheme-shell, with all the text after the ‘\’ taken as part of the meta-argument. More precisely, #! calls interpreter with any options on the second line of the Scheme-Script up to ‘!#’, the name of the Scheme-Script file, and then any of at most 8 arguments given on the command line invoking this Scheme-Script.

The previous example Scheme-Script works in both MS-DOS and unix systems.

Next: , Previous: , Up: Scripting   [Contents][Index]