From 69f84b4101313abc025189b2dbdc57d9b6e4849e Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Mon, 22 Aug 2022 09:53:24 -0700 Subject: [PATCH] Handle 'eshell-pipe-broken' when evaluating Lisp forms in Eshell * lisp/eshell/esh-cmd.el (eshell-exec-lisp): Handle 'eshell-pipe-broken'. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/pipeline-connection-type/middle) (esh-proc-test/pipeline-connection-type/last): Remove ':unstable'. --- lisp/eshell/esh-cmd.el | 9 +++++++++ test/lisp/eshell/esh-proc-tests.el | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 2f77f3f497..3886a1c086 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -1347,6 +1347,15 @@ eshell-exec-lisp (apply func-or-form args))))) (and result (funcall printer result)) result) + (eshell-pipe-broken + ;; If FUNC-OR-FORM tried and failed to write some output to a + ;; process, it will raise an `eshell-pipe-broken' signal (this is + ;; analogous to SIGPIPE on POSIX systems). In this case, set the + ;; command status to some non-zero value to indicate an error; to + ;; match GNU/Linux, we use 141, which is 128 + 13 (the numeric + ;; value of SIGPIPE on GNU/Linux). + (setq eshell-last-command-status 141) + nil) (error (setq eshell-last-command-status 1) (let ((msg (error-message-string err))) diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index 62e784e8f6..2369bb5cc0 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -74,8 +74,6 @@ esh-proc-test/pipeline-connection-type/first (ert-deftest esh-proc-test/pipeline-connection-type/middle () "Test that all streams are pipes when a command is in the middle of a pipeline." - ;; Repeated unreproducible errors. - :tags '(:unstable) (skip-unless (and (executable-find "sh") (executable-find "cat"))) (eshell-command-result-equal @@ -84,8 +82,6 @@ esh-proc-test/pipeline-connection-type/middle (ert-deftest esh-proc-test/pipeline-connection-type/last () "Test that only output streams are PTYs when a command ends a pipeline." - ;; Repeated unreproducible errors. - :tags '(:unstable) (skip-unless (executable-find "sh")) (eshell-command-result-equal (concat "echo | " esh-proc-test--detect-pty-cmd) -- 2.25.1