From 68febcf9f5e5999391e2ec7a8bb8f545b97ed7fe Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 22 Jan 2023 22:54:53 -0800 Subject: [PATCH] Don't try to make a pipe process for remote processes in Eshell Tramp currently isn't able to handle this, so the result will just produce an error. * lisp/eshell/esh-proc.el (eshell-gather-process-output): Check for a remote 'default-directory' before trying to make a pipe process. * test/lisp/eshell/esh-proc-tests.el (esh-var-test/output/remote-redirect): New test. --- lisp/eshell/esh-proc.el | 9 +++++++-- test/lisp/eshell/esh-proc-tests.el | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 9bae812c922..27cd521e82e 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -296,8 +296,13 @@ eshell-gather-process-output 'unix)))) (cond ((fboundp 'make-process) - (unless (equal (car (aref eshell-current-handles eshell-output-handle)) - (car (aref eshell-current-handles eshell-error-handle))) + (unless (or ;; FIXME: It's not currently possible to use a + ;; stderr process for remote files. + (file-remote-p default-directory) + (equal (car (aref eshell-current-handles + eshell-output-handle)) + (car (aref eshell-current-handles + eshell-error-handle)))) (eshell-protect-handles eshell-current-handles) (setq stderr-proc (make-pipe-process diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index ae7b1dddd69..8e02fbb5497 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -19,6 +19,7 @@ ;;; Code: +(require 'tramp) (require 'ert) (require 'esh-mode) (require 'eshell) @@ -85,6 +86,18 @@ esh-proc-test/output/stdout-and-stderr-to-buffer "\\`\\'")) (should (equal (buffer-string) "stdout\nstderr\n")))) +(ert-deftest esh-var-test/output/remote-redirect () + "Check that redirecting stdout for a remote process works." + (skip-unless (and (eshell-tests-remote-accessible-p) + (executable-find "echo"))) + (let ((default-directory ert-remote-temporary-file-directory)) + (eshell-with-temp-buffer bufname "old" + (with-temp-eshell + (eshell-match-command-output + (format "*echo hello > #<%s>" bufname) + "\\`\\'")) + (should (equal (buffer-string) "hello\n"))))) + ;; Exit status -- 2.25.1