Subject: Re: bug#33791: 26.1; Eshell on Windows connecting to GNU/Linux machine using TRAMP and plink: env: ‘c:/home/jordan/test.sh’: No such file or directory

From: Eli Zaretskii <[email-masked]>
Date: Sat, 29 Dec 2018 11:10:52 +0200

> From: Jordan Wilson <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Fri, 28 Dec 2018 19:25:59 +0000
> 
> - Have putty in $PATH (version 0.70 on my machine)
> - Load Eli's/Michael's patched files.el (error appears regardless)
>     (load "files.el")
> - M-x eshell
> - connect to GNU/Linux machine using plink:
>       /plink:[email-masked]:/home/jordan/
> - run executable in working directory
>       ./test.sh
> returns "env: ‘c:/home/jordan/test.sh’: No such file or directory"

Right, I see this as well.

Michael, I need your help here.  The problem is in this part of
eshell-gather-process-output:

    (cond
     ((fboundp 'start-file-process)
      (setq proc
	    (let ((process-connection-type
		   (unless (eshell-needs-pipe-p command)
		     process-connection-type))
		  (command (file-local-name command)))
	      (apply 'start-file-process
		     (file-name-nondirectory command) nil
		     ;; `start-process' can't deal with relative filenames.
		     (append (list (expand-file-name command)) args))))

The problem is that file-local-name returns a Unix-style absolute file
name /foo/bar/baz, and the following expand-file-name call then
prepends a drive letter on Windows, because there's no longer any sign
of COMMAND being a remote file, and so expand-file-name doesn't invoke
the Tramp handler.

The simplest fix is to remove the expand-file-name call.  I don't
understand why it is there, but the claim that start-process cannot
deal with relative file names is definitely false.  This code was
there since June 2000, when eshell-gather-process-output was first
written.  Do you see any reason why we'd need to call expand-file-name
here?

Btw, isn't it confusing that start-file-process needs only the "local"
part of COMMAND?  Why cannot its handler DTRT internally instead?

Thanks.