--- a/lisp/clhs.lisp Wed Dec 19 14:07:58 2018 -0500
+++ b/lisp/clhs.lisp Wed Dec 19 17:44:03 2018 -0500
@@ -117,23 +117,23 @@
:reduce #'adopt:newest))
(defun toplevel ()
- (multiple-value-bind (arguments options) (adopt:parse-options *ui*)
- (when (gethash 'help options)
- (adopt:print-usage *ui*)
- (adopt:exit 0))
- (let ((*open* (gethash 'open options))
- (*url* (gethash 'url options))
- (target (first arguments)))
- (if (gethash 'rebuild-cache options)
- (rebuild-cache)
- (progn
- (when (/= (length arguments) 1)
- (cerror "Type a symbol"
- "Exactly one symbol to look up must be provided (got ~D: ~S)"
- (length arguments)
- arguments)
- (setf arguments (list (read-line))))
- (unless (run target)
- (format *error-output* "Symbol not found: ~A~%" target)
- (adopt:exit 1)))))))
-
+ (handler-case
+ (multiple-value-bind (arguments options) (adopt:parse-options *ui*)
+ (when (gethash 'help options)
+ (adopt:print-usage-and-exit *ui*))
+ (let ((*open* (gethash 'open options))
+ (*url* (gethash 'url options))
+ (target (first arguments)))
+ (if (gethash 'rebuild-cache options)
+ (rebuild-cache)
+ (progn
+ (when (/= (length arguments) 1)
+ (cerror "Type a symbol"
+ "Exactly one symbol to look up must be provided (got ~D: ~S)"
+ (length arguments)
+ arguments)
+ (setf arguments (list (read-line))))
+ (unless (run target)
+ (print-error-and-exit
+ (format nil "Symbol not found: ~A~%" target)))))))
+ (error (c) (adopt:print-error-and-exit c))))