From f542a4537e430cee38d8ddb9c64e0bef393ae03a Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Tue, 12 Sep 2023 18:13:52 -0700 Subject: [PATCH] ; Improve recent change to printing exit status in Eshell * lisp/eshell/esh-proc.el (eshell-interactive-filter): Declare. (eshell-interactive-process-filter): Simplify. (eshell-sentinel): Call 'eshell-interactive-filter'. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill-process/redirect-message): Use 'eshell-with-temp-buffer'. --- lisp/eshell/esh-proc.el | 6 +++--- test/lisp/eshell/esh-proc-tests.el | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 5bfcbd6dc15..5df68947ec2 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -112,6 +112,7 @@ To add or remove elements of this list, see `eshell-record-process-object' and `eshell-remove-process-entry'.") (declare-function eshell-send-eof-to-process "esh-mode") +(declare-function eshell-interactive-filter "esh-mode" (buffer string)) (declare-function eshell-tail-process "esh-cmd") (defvar-keymap eshell-proc-mode-map @@ -437,8 +438,6 @@ This is done after all necessary filtering has been done." 'process (format-message "received output from process `%s'\n\n%s" process string)) (eshell--mark-as-output 0 (length string) string) - (require 'esh-mode) - (declare-function eshell-interactive-filter "esh-mode" (buffer string)) (eshell-interactive-filter (if process (process-buffer process) (current-buffer)) string))) @@ -511,7 +510,8 @@ PROC is the process that's exiting. STRING is the exit message." (eshell-interactive-output-p eshell-error-handle handles) (not (string-match "^\\(finished\\|exited\\)" string))) - (eshell-output-object string eshell-error-handle handles)) + (eshell--mark-as-output 0 (length string) string) + (eshell-interactive-filter (process-buffer proc) string)) (process-put proc :eshell-pending nil) ;; If we're in the middle of handling output from this ;; process then schedule the EOF for later. diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index 52f8aeaedbe..d58764ac29f 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -316,11 +316,10 @@ write the exit status to the pipe. See bug#54136." (ert-deftest esh-proc-test/kill-process/redirect-message () "Test that killing a process with a redirected stderr omits the exit status." (skip-unless (executable-find "sleep")) - (with-temp-buffer - (let ((tempbuf (current-buffer))) - (with-temp-eshell - (eshell-insert-command (format "sleep 100 2> #" tempbuf)) - (kill-process (eshell-head-process)))) + (eshell-with-temp-buffer bufname "" + (with-temp-eshell + (eshell-insert-command (format "sleep 100 2> #" bufname)) + (kill-process (eshell-head-process))) (should (equal (buffer-string) "")))) -- 2.39.5