Subject: bug#65551: 29.1; Eshell on MS-Windows using plink: 'plink' is not recognized as an internal or external command...

From: Jim Porter <[email-masked]>
Date: Sun, 27 Aug 2023 11:48:36 -0700

On 8/27/2023 10:50 AM, Michael Albinus wrote:
> First I try to understand the scenario Eshell is using. If Eshell has
> changed to a remote directory, and a command like "./test.sh" is called,
> I would expect a synchronous process. But this doesn't seem to be the case:
> 
>>    tramp-file-name-handler(make-process :name "test.sh" :buffer #<killed buffer> :command ("/home/username/test.sh") :filter eshell-output-filter :sentinel eshell-sentinel :connection-type nil :stderr nil :file-handler t)
>>    eshell-gather-process-output("/plink:[email-masked]:/home/username/test.s..." nil)
>>    eshell-external-command("./test.sh" nil)
> 
> `make-process' is called, an asynchronous process. Is this intended? Has
> this been changed since Emacs 28?

Yeah, that's intended. A couple of things did change in Emacs 29, but 
Eshell has always used an asynchronous process here. The goal is for the 
process to be only partially synchronous: Eshell will wait until the 
process is done before proceeding (e.g. to emit the next prompt), but it 
also wants to be async so that you can do other things in Emacs while 
waiting for the process to complete.

> Second, I've played a little bit on MS Windows. I haven't installed
> Emacs 29 there, just an Emacs git master checkout. And plink is not in
> the PATH of my MINGW64 bash shell, so I'm using sshx. But everything
> works under this constellation:

I'm using sshx locally to test this, and can reproduce the issue. Maybe 
your MINGW64 configuration is smoothing over the bug for you. When I 
tested this, I started from the MS-Windows "cmd.exe" and ran "emacs -Q", 
with "ssh.exe" in my PATH.

In Emacs 28, this worked fine, but it regressed in 29. I believe this is 
due to commit cee1cbfd54375cdece23d4741ced6b0c7091f6d9, which changes 
how Eshell manages its PATH env var.

I think what Eshell would want here is to set its environment variables 
*only* for the subprocess it creates via 'make-process'. For local 
subprocesses, I don't think we need to do anything fancy, but for the 
remote case, we'd need a way to say "use the original 
process-environment for all the Tramp code, but use this new 
process-environment for the actual subprocess". Maybe there's already a 
way to do this, or maybe we need to add some new powers to 
'make-process' or something...