; 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'.
This commit is contained in:
Jim Porter 2023-09-12 18:13:52 -07:00
parent d1d311a3b2
commit f542a4537e
2 changed files with 7 additions and 8 deletions

View file

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

View file

@ -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> #<buffer %s>" tempbuf))
(kill-process (eshell-head-process))))
(eshell-with-temp-buffer bufname ""
(with-temp-eshell
(eshell-insert-command (format "sleep 100 2> #<buffer %s>" bufname))
(kill-process (eshell-head-process)))
(should (equal (buffer-string) ""))))