Re: Exit with error code when stdin ends in debugger?

Richard M Kreuter via Sbcl-help <[email protected]> Sat, 14 Dec 2024 18:13:14 -0500
Newsgroups gmane.lisp.steel-bank.general
Message-ID <[email protected]>
Sven Michael Klose writes:

> It'd be practical to be able to exit the debugger manually (Ctrl-D)
> after tossing around things a bit, without the rest of the parent
> script (like a build script) continuing anyway...

SBCL's debugger invokes the ABORT restart when *DEBUG-IO* reaches
end-of-file. You can establish an ABORT that makes SBCL exit, e.g.,

  (restart-case <form>
    (abort () :report "Exit SBCL." (sb-ext:exit :code 1)))

This way, in a development context, invoking ABORT in code or forcing
EOF at the debugger or will return you to a Lisp command level (probably
the toplevel, unless your program does nested command levels), but you
can wrap things up for "deployment" so that the same code & user habits
will return you to an OS prompt.

Regards,
Richard