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 (bug#61024).

* 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.
This commit is contained in:
Jim Porter 2023-01-22 22:54:53 -08:00
parent cb9628373a
commit 7f438ff543
2 changed files with 20 additions and 2 deletions

View file

@ -296,8 +296,13 @@ Used only on systems which do not support async subprocesses.")
'unix)))) 'unix))))
(cond (cond
((fboundp 'make-process) ((fboundp 'make-process)
(unless (equal (car (aref eshell-current-handles eshell-output-handle)) (unless (or ;; FIXME: It's not currently possible to use a
(car (aref eshell-current-handles eshell-error-handle))) ;; 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) (eshell-protect-handles eshell-current-handles)
(setq stderr-proc (setq stderr-proc
(make-pipe-process (make-pipe-process

View file

@ -19,6 +19,7 @@
;;; Code: ;;; Code:
(require 'tramp)
(require 'ert) (require 'ert)
(require 'esh-mode) (require 'esh-mode)
(require 'eshell) (require 'eshell)
@ -85,6 +86,18 @@
"\\`\\'")) "\\`\\'"))
(should (equal (buffer-string) "stdout\nstderr\n")))) (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 ;; Exit status