Use 'sh:exit' for 'errexit'.

* gash/shell.scm (errexit): Exit using 'sh:exit'.
* tests/unit/shell.scm: Make sure exit handlers are called on
'errexit'.
This commit is contained in:
Timothy Sample 2019-06-07 19:39:03 -04:00
parent da9a05d500
commit d9122d7b68
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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)