unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process
@ 2023-01-23  7:07 Jim Porter
  2023-01-23 13:21 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Porter @ 2023-01-23  7:07 UTC (permalink / raw)
  To: 61024

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

To see this in action, run "emacs -Q -f eshell" and then:

   ~ $ cd /sudo::
   /sudo:root@host:~ # *echo hi there > #<foo>
   Wrong type argument: "bufferp echo-stderr"

(Any other Tramp method should reproduce this issue.) That's because the 
echo command is being redirected to two places: stdout is going to the 
buffer "foo", and stderr is going to the Eshell buffer (via a pipe 
process). However, that doesn't work for Tramp processes.

Attached is a fix with a test. I think this should definitely go in 
Emacs 29, since it's a pretty bad regression. I'm actually surprised no 
one has filed a bug on this already.

For tracking purposes, I believe this was broken by f07505d1ec (bug#21605).

For Emacs 30, it'd be interesting to see if there were a way to get 
Tramp processes to have different targets for stdout and stderr. That'd 
make them work a lot more like local processes in Eshell.

[-- Attachment #2: 0001-Don-t-try-to-make-a-pipe-process-for-remote-processe.patch --]
[-- Type: text/plain, Size: 2718 bytes --]

From 68febcf9f5e5999391e2ec7a8bb8f545b97ed7fe Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
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")))))
+
 \f
 ;; Exit status
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process
  2023-01-23  7:07 bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process Jim Porter
@ 2023-01-23 13:21 ` Eli Zaretskii
  2023-01-23 15:50   ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-01-23 13:21 UTC (permalink / raw)
  To: Jim Porter; +Cc: 61024

> Date: Sun, 22 Jan 2023 23:07:58 -0800
> From: Jim Porter <jporterbugs@gmail.com>
> 
>    ~ $ cd /sudo::
>    /sudo:root@host:~ # *echo hi there > #<foo>
>    Wrong type argument: "bufferp echo-stderr"
> 
> (Any other Tramp method should reproduce this issue.) That's because the 
> echo command is being redirected to two places: stdout is going to the 
> buffer "foo", and stderr is going to the Eshell buffer (via a pipe 
> process). However, that doesn't work for Tramp processes.
> 
> Attached is a fix with a test. I think this should definitely go in 
> Emacs 29, since it's a pretty bad regression.

Fine by me, unless Michael objects or has better ideas.

> I'm actually surprised no one has filed a bug on this already.

Maybe it tells us how many people use this combination?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process
  2023-01-23 13:21 ` Eli Zaretskii
@ 2023-01-23 15:50   ` Michael Albinus
  2023-01-23 17:47     ` Jim Porter
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2023-01-23 15:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61024, Jim Porter

Eli Zaretskii <eliz@gnu.org> writes:

Hi,

>>    ~ $ cd /sudo::
>>    /sudo:root@host:~ # *echo hi there > #<foo>
>>    Wrong type argument: "bufferp echo-stderr"
>>
>> (Any other Tramp method should reproduce this issue.) That's because the
>> echo command is being redirected to two places: stdout is going to the
>> buffer "foo", and stderr is going to the Eshell buffer (via a pipe
>> process). However, that doesn't work for Tramp processes.
>>
>> Attached is a fix with a test. I think this should definitely go in
>> Emacs 29, since it's a pretty bad regression.
>
> Fine by me, unless Michael objects or has better ideas.

Pipe processes are always tricky for Tramp. I *believe* redirecting
stdout and stderr to different buffers shall work, see "test6" of
tramp-test30-make-process. But I remember also that this was painful to
implement and test.

>> I'm actually surprised no one has filed a bug on this already.
>
> Maybe it tells us how many people use this combination?

So do we want to reopen this can of worms, and see what happens with
Tramp? But perhaps it is a problem in Eshell, which tries to create its
own pipe process?

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process
  2023-01-23 15:50   ` Michael Albinus
@ 2023-01-23 17:47     ` Jim Porter
  2023-01-23 17:51       ` Jim Porter
  2023-01-23 18:25       ` Michael Albinus
  0 siblings, 2 replies; 6+ messages in thread
From: Jim Porter @ 2023-01-23 17:47 UTC (permalink / raw)
  To: Michael Albinus, Eli Zaretskii; +Cc: 61024

On 1/23/2023 7:50 AM, Michael Albinus wrote:
> Pipe processes are always tricky for Tramp. I *believe* redirecting
> stdout and stderr to different buffers shall work, see "test6" of
> tramp-test30-make-process. But I remember also that this was painful to
> implement and test.

Yeah, I took a look at the Tramp code and it's pretty tricky. I'll see 
if I can come up with something for Emacs 30 though (maybe we could 
update the 'make-process' API to make this easier for Tramp?).

I'll merge this simple fix to Emacs 29 shortly then.

>>> I'm actually surprised no one has filed a bug on this already.
>>
>> Maybe it tells us how many people use this combination?
> 
> So do we want to reopen this can of worms, and see what happens with
> Tramp? But perhaps it is a problem in Eshell, which tries to create its
> own pipe process?

I'd certainly expect to see bug reports if this had shipped as part of a 
final Emacs release, but I think it does say that not many people use 
Tramp + Eshell on development builds. (Which, if anything, is mostly a 
sign to me that I need to be extra-careful when testing combinations of 
features like this, since people might not report bugs until after the 
release.)





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process
  2023-01-23 17:47     ` Jim Porter
@ 2023-01-23 17:51       ` Jim Porter
  2023-01-23 18:25       ` Michael Albinus
  1 sibling, 0 replies; 6+ messages in thread
From: Jim Porter @ 2023-01-23 17:51 UTC (permalink / raw)
  To: Michael Albinus, Eli Zaretskii; +Cc: 61024

On 1/23/2023 9:47 AM, Jim Porter wrote:
> I'll merge this simple fix to Emacs 29 shortly then.

Ok, merged to Emacs 29 as 7f438ff543. I'll leave this open though so we 
can discuss a better fix for Emacs 30.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process
  2023-01-23 17:47     ` Jim Porter
  2023-01-23 17:51       ` Jim Porter
@ 2023-01-23 18:25       ` Michael Albinus
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Albinus @ 2023-01-23 18:25 UTC (permalink / raw)
  To: Jim Porter; +Cc: 61024, Eli Zaretskii

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

>> Pipe processes are always tricky for Tramp. I *believe* redirecting
>> stdout and stderr to different buffers shall work, see "test6" of
>> tramp-test30-make-process. But I remember also that this was painful to
>> implement and test.
>
> Yeah, I took a look at the Tramp code and it's pretty tricky. I'll see
> if I can come up with something for Emacs 30 though (maybe we could
> update the 'make-process' API to make this easier for Tramp?).

Pls do. Let's see where we land.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-23 18:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-23  7:07 bug#61024: 29.0.60; [PATCH] Eshell errors out when trying to redirect output of a remote process Jim Porter
2023-01-23 13:21 ` Eli Zaretskii
2023-01-23 15:50   ` Michael Albinus
2023-01-23 17:47     ` Jim Porter
2023-01-23 17:51       ` Jim Porter
2023-01-23 18:25       ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).