Next: , Up: Guile Scripting


9.1 Invoking Guile

Here we describe Guile's command-line processing in detail. Guile processes its arguments from left to right, recognizing the switches described below. For examples, see Scripting Examples.

-s script arg...
Read and evaluate Scheme source code from the file script, as the load function would. After loading script, exit. Any command-line arguments arg... following script become the script's arguments; the command-line function returns a list of strings of the form (script arg...).

Recent versions of Guile do not require the -s; it is optional. When -s is omitted, script must not begin with - (hyphen) as that would confuse the argument parser.

-c expr arg...
Evaluate expr as Scheme code, and then exit. Any command-line arguments arg... following expr become command-line arguments; the command-line function returns a list of strings of the form (guile arg...), where guile is the path of the Guile executable.
-- arg...
Run interactively, prompting the user for expressions and evaluating them. Any command-line arguments arg... following the -- become command-line arguments for the interactive session; the command-line function returns a list of strings of the form (guile arg...), where guile is the path of the Guile executable.
-L directory
Add directory to the front of Guile's module load path. If specified multiple times, Guile searches the directories in the order given on the command line and before any directories in the GUILE_LOAD_PATH environment variable. Paths added here are not in effect during execution of the user's .guile file.
-l file
Load Scheme source code from file, and continue processing the command line.
-e entrypoint
Make entrypoint the entry point of the script. After loading the script file (with -s) or evaluating the expression (with -c), apply entrypoint to a list containing the program name and the command-line arguments — the list provided by the command-line function. entrypoint can name:

A module name is a list of symbols surrounded by parentheses, such as (scripts frisk) or (my code fred). Remember to quote the argument to the -e switch in these cases to protect against possible shell misinterpretation.

A -e switch can appear anywhere in the argument list, but Guile always invokes the function as the last action it performs. This is weird, but because of the way script invocation works under POSIX, the -s option must always come last in the list.

See Scripting Examples.

-ds
Treat a final -s option as if it occurred at this point in the command line; load the script here.

This switch is necessary because, although the POSIX script invocation mechanism effectively requires the -s option to appear last, the programmer may well want to run the script before other actions requested on the command line. For examples, see Scripting Examples.

\
Read more command-line arguments, starting from the second line of the script file. See The Meta Switch.
--emacs
Assume Guile is running as an inferior process of Emacs, and use a special protocol to communicate with Emacs's Guile interaction mode. This switch is still experimental.
--debug
Start with the debugging evaluator and enable backtraces. Using the debugging evaluator will give you better error messages but it will slow down execution. By default, the debugging evaluator is only used when entering an interactive session. When executing a script with -s or -c, the normal, faster evaluator is used by default.
-h, --help
Display help on invoking Guile, and then exit.
-v, --version
Display the current version of Guile, and then exit.