Don Geddis <don@geddis.org> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) wrote on Fri, 11 Jul 2008:
| > [2] Yes, I've been talking to Carl Shapiro about whether or how to
| > get the "#!" hack [or equiv.] into the standard CMUCL distribution.
| > As you can see from the code, there's *lots* of room for conflicting
| > opinions over what "doing it right" might mean. ;-}
|
| I would definitely support this effort.
|
| Given the popularity of the unix/lisp combination, and the popularity of
| "shell" scripting on unix, doing #! in lisp is a high-value addition.
|
| Is there anything an outsider like me could do, to assist you and/or Carl
| in adding this functionality?
+---------------
Grab a copy of <http://rpw3.org/hacks/lisp/site-switch-script.lisp>,
follow the "Installation & usage:" instructions in the comments,
use it a while, and then let me know what's good or not so good
about it. And if not so good, how you'd propose to improve it.
I've been using it *heavily* since I wrote it in late 2003, and have
made only two small tweaks[1] since then, so I consider it quite stable,
at least for the things *I* tend to do. But more eyes would be helpful...
And, oh, the one thing I've been thinking about adding as a builtin
(but overrideable) default -- is to exit on ^C (SIGINT) rather than
drop into the debugger. I've tended to add it as the end of a number
of my scripts, like so:
(defun my-sigint (signal code scp)
(declare (ignore signal code scp))
(unix:unix-exit 1)
(error "Unix-exit failed to exit!"))
(unless *script-exit-hooks* ; Debugging?
;; This program is usually used from the shell, where the most
;; commonly-desired behavior upon receiving SIGINT is to simply exit.
(system:with-enabled-interrupts ((unix:sigint #'my-sigint))
(main)))
but it probably should be done for everybody in "site-switch-script" [but
using SYSTEM:ENABLE-INTERRUPT rather than SYSTEM:WITH-ENABLED-INTERRUPTS].
I look forward to your comments after you've used it for a while.
-Rob
[1] 1. Add *GC-VERBOSE* and *COMPILE-VERBOSE* to the set of symbols
bound to NIL during script execution.
2. Replace the [no longer present] "-fasl" option with slightly
more smarts in "-script", so that "-script" can be used with
either CL source or CMUCL FASLs.
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607