1 @node Starting and Stopping
2 @comment node-name, next, previous, up
3 @chapter Starting and Stopping
8 * Command Line Options::
9 * Initialization Files::
10 * Initialization and Exit Hooks::
14 @comment node-name, next, previous, up
15 @section Starting SBCL
18 * Running from Shell::
19 * Running from Emacs::
23 @node Running from Shell
24 @comment node-name, next, previous, up
25 @subsection From Shell to Lisp
27 To run SBCL type @command{sbcl} at the command line.
29 You should end up in the toplevel @dfn{REPL} (read, eval, print
30 -loop), where you can interact with SBCL by typing expressions.
34 This is SBCL 0.8.13.60, an implementation of ANSI Common Lisp.
35 More information about SBCL is available at <http://www.sbcl.org/>.
37 SBCL is free software, provided as is, with absolutely no warranty.
38 It is mostly in the public domain; some portions are provided under
39 BSD-style licenses. See the CREDITS and COPYING files in the
40 distribution for more information.
48 See also @ref{Command Line Options} and @ref{Stopping SBCL}.
50 @node Running from Emacs
51 @comment node-name, next, previous, up
52 @subsection Running from Emacs
54 To run SBCL as an inferior-lisp from Emacs in your @file{.emacs} do
58 ;;; The SBCL binary and command-line arguments
59 (setq inferior-lisp-program "/usr/local/bin/sbcl --noinform")
62 For more information on using SBCL with Emacs, see @ref{Editor
67 @comment node-name, next, previous, up
68 @subsection Shebang Scripts
69 @vindex @sbext{@earmuffs{posix-argv}}
71 Standard Unix tools that are interpreters follow a common command line
72 protocol that is necessary to work with ``shebang scripts''. SBCL supports
73 this via the @code{--script} command line option.
75 Example file (@file{hello.lisp}):
78 #!/usr/local/bin/sbcl --script
79 (write-line "Hello, World!")
90 $ sbcl --script hello.lisp
95 @comment node-name, next, previous, up
96 @section Stopping SBCL
101 * Saving a Core Image::
106 @comment node-name, next, previous, up
109 SBCL can be stopped at any time by calling @code{sb-ext:quit},
110 optionally returning a specified numeric value to the calling process.
111 See notes in @ref{Threading} about the interaction between this
112 feature and sessions.
114 @include fun-sb-ext-quit.texinfo
117 @comment node-name, next, previous, up
118 @subsection End of File
120 By default SBCL also exits on end of input, caused either by user
121 pressing @kbd{Control-D} on an attached terminal, or end of input when
122 using SBCL as part of a shell pipeline.
124 @node Saving a Core Image
125 @comment node-name, next, previous, up
126 @subsection Saving a Core Image
128 SBCL has the ability to save its state as a file for later
129 execution. This functionality is important for its bootstrapping
130 process, and is also provided as an extension to the user.
132 @include fun-sb-ext-save-lisp-and-die.texinfo
133 @include var-sb-ext-star-save-hooks-star.texinfo
135 To facilitate distribution of SBCL applications using external
136 resources, the filesystem location of the SBCL core file being used is
139 @include var-sb-ext-star-core-pathname-star.texinfo
142 @comment node-name, next, previous, up
143 @subsection Exit on Errors
145 SBCL can also be configured to exit if an unhandled error occurs,
146 which is mainly useful for acting as part of a shell pipeline; doing
147 so under most other circumstances would mean giving up large parts of
148 the flexibility and robustness of Common Lisp. See @ref{Debugger Entry}.
150 @node Command Line Options
151 @comment node-name, next, previous, up
152 @section Command Line Options
154 @c FIXME: This is essentially cut-and-paste from the manpage
155 @c What should probably be done is generate both this and the
156 @c man-page from ``sbcl --help'' output.
158 Command line options can be considered an advanced topic; for ordinary
159 interactive use, no command line arguments should be necessary.
161 In order to understand the command line argument syntax for SBCL, it
162 is helpful to understand that the SBCL system is implemented as two
163 components, a low-level runtime environment written in C and a
164 higher-level system written in Common Lisp itself. Some command line
165 arguments are processed during the initialization of the low-level
166 runtime environment, some command line arguments are processed during
167 the initialization of the Common Lisp system, and any remaining
168 command line arguments are passed on to user code.
170 The full, unambiguous syntax for invoking SBCL at the command line is:
172 @command{sbcl} @var{runtime-option}* @code{--end-runtime-options} @var{toplevel-option}* @code{--end-toplevel-options} @var{user-options}*
174 For convenience, the @code{--end-runtime-options} and
175 @code{--end-toplevel-options} elements can be omitted. Omitting these
176 elements can be convenient when you are running the program
177 interactively, and you can see that no ambiguities are possible with
178 the option values you are using. Omitting these elements is probably a
179 bad idea for any batch file where any of the options are under user
180 control, since it makes it impossible for SBCL to detect erroneous
181 command line input, so that erroneous command line arguments will be
182 passed on to the user program even if they was intended for the
183 runtime system or the Lisp system.
190 @node Runtime Options
191 @comment node-name, next, previous, up
192 @subsection Runtime Options
196 @item --core @var{corefilename}
197 Run the specified Lisp core file instead of the default. Note that if
198 the Lisp core file is a user-created core file, it may run a
199 nonstandard toplevel which does not recognize the standard toplevel
202 @item --dynamic-space-size @var{megabytes}
203 Size of the dynamic space reserved on startup in megabytes. Default
204 value is platform dependent.
206 @item --control-stack-size @var{megabytes}
207 Size of control stack reserved for each thread in megabytes. Default
211 Suppress the printing of any banner or other informational message at
212 startup. This makes it easier to write Lisp programs which work
213 cleanly in Unix pipelines. See also the @code{--noprint} and
214 @code{--disable-debugger} options.
218 @cindex ldb, disabling
219 @cindex disabling ldb
220 Disable the low-level debugger. Only effective if SBCL is compiled
223 @item --lose-on-corruption
225 There are some dangerous low level errors (for instance, control stack
226 exhausted, memory fault) that (or whose handlers) can corrupt the
227 image. By default SBCL prints a warning, then tries to continue and
228 handle the error in Lisp, but this will not always work and SBCL may
229 malfunction or even hang. With this option, upon encountering such an
230 error SBCL will invoke ldb (if present and enabled) or else exit.
233 @item --script @var{filename}
234 As a runtime option this is equivalent to @code{--noinform}
235 @code{--disable-ldb} @code{--lose-on-corruption}
236 @code{--end-runtime-options} @code{--script} @var{filename}. See the
237 description of @code{--script} as a toplevel option below.
240 Print some basic information about SBCL, then exit.
243 Print SBCL's version information, then exit.
247 In the future, runtime options may be added to control behaviour such
248 as lazy allocation of memory.
250 Runtime options, including any --end-runtime-options option, are
251 stripped out of the command line before the Lisp toplevel logic gets a
254 @node Toplevel Options
255 @comment node-name, next, previous, up
256 @subsection Toplevel Options
260 @item --sysinit @var{filename}
261 Load filename instead of the default system initialization file
262 (@pxref{Initialization Files}.)
265 Don't load a system-wide initialization file. If this option is given,
266 the @code{--sysinit} option is ignored.
268 @item --userinit @var{filename}
269 Load filename instead of the default user initialization file
270 (@pxref{Initialization Files}.)
273 Don't load a user initialization file. If this option is given,
274 the @code{--userinit} option is ignored.
276 @item --eval @var{command}
277 After executing any initialization file, but before starting the
278 read-eval-print loop on standard input, read and evaluate the command
279 given. More than one @code{--eval} option can be used, and all will be
280 read and executed, in the order they appear on the command line.
282 @item --load @var{filename}
283 This is equivalent to @code{--eval '(load "@var{filename}")'}. The
284 special syntax is intended to reduce quoting headaches when invoking
285 SBCL from shell scripts.
288 When ordinarily the toplevel "read-eval-print loop" would be exe-
289 cuted, execute a "read-eval loop" instead, i.e. don't print a prompt
290 and don't echo results. Combined with the @code{--noinform} runtime
291 option, this makes it easier to write Lisp "scripts" which work
292 cleanly in Unix pipelines.
294 @item --disable-debugger
295 By default when SBCL encounters an error, it enters the builtin
296 debugger, allowing interactive diagnosis and possible intercession.
297 This option disables the debugger, causing errors to print a backtrace
298 and exit with status 1 instead. When given, this option takes effect
299 before loading of initialization files or processing @code{--eval} and
300 @code{--load} options. See @code{sb-ext:disable-debugger} for details.
301 @xref{Debugger Entry}.
303 @item --script @var{filename}
304 Implies @code{--no-userinit} @code{--no-sysinit}
305 @code{--disable-debugger} @code{--end-toplevel-options}.
307 Causes the system to load the specified file instead of entering the
308 read-eval-print-loop, and exit afterwards. If the file begins with a
309 shebang line, it is ignored.
313 @node Initialization Files
314 @comment node-name, next, previous, up
315 @section Initialization Files
317 SBCL processes initialization files with @code{read} and @code{eval},
318 not @code{load}; hence initialization files can be used to set startup
319 @code{*package*} and @code{*readtable*}, and for proclaiming a global
324 @strong{System Initialization File}
326 Defaults to @file{@env{$SBCL_HOME}/sbclrc}, or if that doesn't exist to
327 @file{/etc/sbclrc}. Can be overridden with the command line option
328 @code{--sysinit} or @code{--no-sysinit}.
330 The system initialization file is intended for system administrators
331 and software packagers to configure locations of installed third party
335 @strong{User Initialization File}
337 Defaults to @file{@env{$HOME}/.sbclrc}. Can be overridden with the
338 command line option @code{--userinit} or @code{--no-userinit}.
340 The user initialization file is intended for personal customizations,
341 such as loading certain modules at startup, defining convenience
342 functions to use in the REPL, handling automatic recompilation
343 of FASLs (@pxref{FASL Format}), etc.
347 Neither initialization file is required.
349 @node Initialization and Exit Hooks
350 @comment node-name, next, previous, up
351 @section Initialization and Exit Hooks
353 SBCL provides hooks into the system initialization and exit.
355 @include var-sb-ext-star-init-hooks-star.texinfo
356 @include var-sb-ext-star-exit-hooks-star.texinfo