MzScheme accepts the following flags:
Startup file and expression flags:
file: Use this flag for MzScheme-based scripts. It mutes the startup banner printout, suppresses the
fileafter MzScheme starts. No argument after
fileis treated as a flag. The -r or --script flag is a shorthand for -fmv-.
file: Same as -r
file, except that the current directory is changed to
file's directory before it is loaded. The -i or --script-cd flag is a shorthand for -dmv-.
m: Loads code embedded in the executable from file position
mafter MzScheme starts. This flag is useful for creating a stand-alone binary by appending code to the normal MzScheme executable. See PLT mzc: MzScheme Compiler Manual for more details.
-C or --main : Like -r, then calls the function bound to
mainin the top-level environment. The argument to
mainis a list of immutable strings; the first string is the path of the file that was loaded, and the rest of the list contains leftover command-line arguments (the ones installed in
mainfunction is called only if no previous evaluations or loads resulted in an uncaught exception.
-x or --no-lib-path : Suppresses the initialization of
current-library-collection-paths(as described in Chapter 16).
Language setting flags:
file: Restores a saved image (see section 14.5). Extra arguments after
fileare returned as a vector of strings to the continuation of the
write-image-to-filecall that created the image.
Extra arguments following the last flag are available from the
current-command-line-arguments parameter (see
as an immutable vector of immutable strings. The name used to start
MzScheme is available from the
(see section 11.3.2)
'exec-file. In addition, unless -A is specified,
the argument vector is put into the global variable
and the name used to start MzScheme is put into the global variable
program as an immutable string.
Multiple single-letter flags (the ones preceded by a single dash) can be collapsed into a single flag by concatenating the letters, as long as the the first flag is not --. The arguments for each flag are placed after the collapsed flags (in the order of the flags). For example,
file -m -e
are equivalent. If a collapsed -- appears before other collapsed flags, it is implicitly moved to the end of the collapsed set.
If the MzScheme executable is given a name of the form
dialect, then the command line is effectively
-qAeC '(require (lib "init.ss" "script-lang" "
The first actual command-line argument thus serves as a file to
load. The file is loaded into a namespace that is initialized by the
dialect-specific init.ss library. The loaded file should
main, which is called with command-line
arguments -- starting with the loaded file name -- as a list of
current-library-collection-paths parameter is
initialized (as described in
Chapter 16) before any expression or file is evaluated or
loaded, unless the -x or --no-lib-path flag is specified.
Unless the -q or --no-init-file flag is specified, a user
initialization file is loaded after
current-library-collection-paths parameter is initialized and
before any other expression or file is evaluated or loaded. The path
to the user initialization file is obtained from MzScheme's
find-system-path procedure using
Expressions and files are evaluated and loaded in order that they are provided on the command line, including calls to main implied by --main, embeddings loaded by -k, and so on. If an uncaught exception occurs, the remaining expressions and files are skipped. The thread that loads the files and evaluates the expressions is the main thread. When the main thread terminates (or is killed), the MzScheme process exits.
The exit status for the MzScheme process indicates an error if an error
occurs evaluating or loading a command-line expression or file and
read-eval-print-loop is not called afterwards, or if the default exit handler
is called with an exact integer between 1 and 255.