Next: Index Up: PLT MzScheme: Language Manual Previous: Transcripts: transcr.ss

# Running MzScheme

The stand-alone version of MzScheme accepts a number of command-line flags. Under MacOS, a user can specify command-line flags by holding down the Command key while starting MzScheme, which provides a dialog for entering the command line. Dragging files onto the MzScheme icon in MacOS is equivalent to providing each file's name on the command line preceded by `-f`, so each file is loaded after MzScheme starts. When files are dragged onto MzScheme with the Command key pressed, the command line specified in the dialog is appended to the implicit command-line for loading the files.

MzScheme accepts the following flags:

- Startup file and expression flags:

  *
    `-e` expr : Evaluates expr after MzScheme starts.

  *
    `-f` file : Loads file after MzScheme starts.

  *
    `-d` file : Uses `load/cd` to load file after MzScheme starts.

  *
    `-F` : Loads each remaining argument as a file after MzScheme starts.

  *
    `-D` : Loads each remaining argument as a file using `load/cd` after MzScheme starts.

  *
    `-l` file : Loads the MzLib library file after MzScheme starts.

  *
    `-L` file collect : Loads the library file in the collection collect after MzScheme starts.

  *
    `-r` file or `--script` file : Use this flag for MzScheme-based scripts. It mutes the startup banner printout, suppresses the `read`-`eval`-`print` loop, and loads file after MzScheme starts. No argument after file is treated as a flag. The `-r` or `--script` flag is a shorthand for `-fmv-`.

  *
    `-i` file or `--script-cd` file : Same as `-r` file or `--script` 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-`.

  *
    `-w` or `--awk` : Loads the `awk.ss` library after MzScheme starts.

  *
    `-k` n m : Loads code embedded in the executable from file position n to m after 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.

- Initialization flags:

  *
    `-x` or `--no-lib-path` : Suppresses the initialization of `current-library-collection-paths` (as described in Chapter 15).

  *
    `-q` or `--no-init-file` : Suppresses loading the user's initialization file, as described below.

- Language setting flags:

  *
    `-g` or `--case-sens` : Creates an initial namespace where identifiers and symbols are case-sensitive.

  *
    `-c` or `--esc-cont` : Creates an initial namespace where `call-with-current-continuation` and `call/cc` capture escape continuations (like `call/ec`) instead of full continuations.

  *
    `-s` or `--set-undef` : Creates an initial namespace where `set!` will successfully mutate an undefined global variable (implicitly defining it).

  *
    `-a` or `--no-auto-else` : Creates an initial namespace where falling through all of the clauses in a `cond` or `case` expression raises the `exn:else` exception.

  *
    `-n` or `--no-key` : Creates an initial namespace where keywords are not enforced.

  *
    `-y` or `--hash-percent-syntax` : Creates an initial namespace that includes only the `#%` syntactic forms.

- Miscellaneous flags:

  *
    `-` : No argument following this flag is used as a flag.

  *
    `-m` or `--mute-banner` : Suppresses the startup banner text.

  *
    `-v` or `--version` : Suppresses the `read`-`eval`-`print` loop.

  *
    `-h` or `--help` : Shows information about MzScheme's command-line flags and then exits; ignoring other flags.

  *
    `-p` or `--persistent` : Catches the SIGDANGER (low page space) signal and ignores it (AIX only).

  *
    `-R`file or `--restore` file : Restores a saved image (see section 14.8). Extra arguments after file are returned as a vector of strings to the continuation of the `write-image-to-file` call that created the image.

Extra arguments following the last flag are put into the Scheme global variable `argv` as a vector of strings. The name used to start MzScheme is put into the global variable `program` as a 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, ``

      -vfme file expr

and `

      -v -f file -m -e expr

` are equivalent.

The `current-library-collection-paths` parameter is initialized (as described in Chapter 15) 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 `'init-file`.

Expressions and files are evaluated and loaded in order that they are provided on the command line. If an error 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.

After the command-line files and expressions are loaded and evaluated, the main thread calls , unless the `-v`, `--version`, `-r`, `--script`, `-i`, `--script-cd` flag is specified.

The exit status for the MzScheme process indicates an error if an error occurs evaluating or loading a command-line expression or file and is not called afterwards, or if the default exit handler is called with an exact integer between 1 and 255.

Next: Index Up: PLT MzScheme: Language Manual Previous: Transcripts: transcr.ss