diff --git a/gash/shell.scm b/gash/shell.scm index b2703c3..fa31557 100644 --- a/gash/shell.scm +++ b/gash/shell.scm @@ -55,7 +55,7 @@ (define (errexit) (unless (or (zero? (get-status)) (ignore-errexit?)) (when (getopt 'errexit) - (exit (get-status))))) + (sh:exit)))) (define (install-current-ports!) "Install all current ports into their usual file descriptors. For diff --git a/tests/unit/shell.scm b/tests/unit/shell.scm index e45f7f2..638f85f 100644 --- a/tests/unit/shell.scm +++ b/tests/unit/shell.scm @@ -447,4 +447,20 @@ (sh:exec utility))) (call-with-input-file foo get-string-all))))) + +;;; Errexit. + +(test-assert "Exit traps are still called on errexit" + (call-with-prompt default-prompt-tag + (lambda () + (set-atexit! (lambda () (abort-to-prompt default-prompt-tag))) + (setopt! 'errexit #t) + (call-with-temporary-directory + (lambda (directory) + (let ((utility (string-append directory "/false"))) + (make-script utility + (exit EXIT_FAILURE)) + (sh:exec utility))))) + (lambda (k) #t))) + (test-end)