-@node Unix-style Command Line Protocol
-@comment node-name, next, previous, up
-@subsubsection Unix-style Command Line Protocol
-@vindex sb-ext:*posix-argv*
-@vindex *posix-argv*
-
-Standard Unix tools that are interpreters follow a common command line
-protocol that is necessary to work with ``shebang scripts''. SBCL
-doesn't do this by default, but adding the following snippet to an
-initialization file does the trick:
-
-@lisp
-;;; If the first user-processable command-line argument is a filename,
-;;; disable the debugger, load the file handling shebang-line and quit.
-(let ((script (and (second *posix-argv*)
- (probe-file (second *posix-argv*)))))
- (when script
- ;; Handle shebang-line
- (set-dispatch-macro-character #\# #\!
- (lambda (stream char arg)
- (declare (ignore char arg))
- (read-line stream)))
- ;; Disable debugger
- (setf *invoke-debugger-hook*
- (lambda (condition hook)
- (declare (ignore hook))
- ;; Uncomment to get backtraces on errors
- ;; (sb-debug:backtrace 20)
- (format *error-output* "Error: ~A~%" condition)
- (quit)))
- (load script)
- (quit)))
-@end lisp
-
-Example file (@file{hello.lisp}):
-
-@lisp
-#!/usr/local/bin/sbcl --noinform
-(write-line "Hello, World!")
-@end lisp
-
-Usage examples:
-
-@smallexample
-$ ./hello.lisp
-Hello, World!
-@end smallexample
-
-@smallexample
-$ sbcl hello.lisp
-This is SBCL 0.8.13.70, an implementation of ANSI Common Lisp.
-More information about SBCL is available at <http://www.sbcl.org/>.
-
-SBCL is free software, provided as is, with absolutely no warranty.
-It is mostly in the public domain; some portions are provided under
-BSD-style licenses. See the CREDITS and COPYING files in the
-distribution for more information.
-Hello, World!
-@end smallexample
-
-