From baaf226cb91a41de66b7dc663c433c67f1c0f0e5 Mon Sep 17 00:00:00 2001 From: Ian Price Date: Sun, 22 Jan 2012 19:47:16 +0000 Subject: [PATCH] Run exit-hook when scripts finish normally. * module/ice-9/command-line.scm (compile-shell-switches): Wrap the body of the output expression in a catch for `quit' exceptions, so that we can run the `exit-hook'. --- module/ice-9/command-line.scm | 68 +++++++++++++++++++++------------------- 1 files changed, 36 insertions(+), 32 deletions(-) diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm index 8aed74e..e33fac8 100644 --- a/module/ice-9/command-line.scm +++ b/module/ice-9/command-line.scm @@ -385,38 +385,42 @@ If FILE begins with `-' the -s switch is mandatory. `(;; It would be nice not to load up (ice-9 control), but the ;; default-prompt-handler is nontrivial. (@ (ice-9 control) %) - (begin - ;; If we didn't end with a -c or a -s and didn't supply a -q, load - ;; the user's customization file. - ,@(if (and interactive? (not inhibit-user-init?)) - '((load-user-init)) - '()) - - ;; Use-specified extensions. - ,@(map (lambda (ext) - `(set! %load-extensions (cons ,ext %load-extensions))) - user-extensions) - - ;; Add the user-specified load path here, so it won't be in - ;; effect during the loading of the user's customization file. - ,@(map (lambda (path) - `(set! %load-path (cons ,path %load-path))) - user-load-path) - - ;; Put accumulated actions in their correct order. - ,@(reverse! out) - - ;; Handle the `-e' switch, if it was specified. - ,@(if entry-point - `((,entry-point (command-line))) - '()) - ,(if interactive? - ;; If we didn't end with a -c or a -s, start the - ;; repl. - '((@ (ice-9 top-repl) top-repl)) - ;; Otherwise, after doing all the other actions - ;; prescribed by the command line, quit. - '(quit))))) + (catch 'quit + (lambda () + ;; If we didn't end with a -c or a -s and didn't supply a -q, load + ;; the user's customization file. + ,@(if (and interactive? (not inhibit-user-init?)) + '((load-user-init)) + '()) + + ;; Use-specified extensions. + ,@(map (lambda (ext) + `(set! %load-extensions (cons ,ext %load-extensions))) + user-extensions) + + ;; Add the user-specified load path here, so it won't be in + ;; effect during the loading of the user's customization file. + ,@(map (lambda (path) + `(set! %load-path (cons ,path %load-path))) + user-load-path) + + ;; Put accumulated actions in their correct order. + ,@(reverse! out) + + ;; Handle the `-e' switch, if it was specified. + ,@(if entry-point + `((,entry-point (command-line))) + '()) + ,(if interactive? + ;; If we didn't end with a -c or a -s, start the + ;; repl. + '((@ (ice-9 top-repl) top-repl)) + ;; Otherwise, after doing all the other actions + ;; prescribed by the command line, quit. + '(quit))) + (lambda args + (run-hook exit-hook) + (apply throw args))))) (if (pair? args) (begin -- 1.7.7.5