[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows
From: |
Michael Albinus |
Subject: |
bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows |
Date: |
Sun, 27 Jun 2021 10:41:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jim Porter <jporterbugs@gmail.com> writes:
Hi Jim,
>> I've pushed a fix to the master branches of Emacs and Tramp. Could you,
>> pls, check?
>
> I tested on MS Windows and it works correctly for me. (Note that I
> just copied and eval'ed the new version of `tramp-file-name-handler',
> since I don't have a proper build environment on MS Windows.)
Thanks for confirmation.
> If I erase the default text and instead enter
> "C:/Windows/System32/cmd.exe" into the `M-x shell' prompt, it treats
> *that* as a remote path too. Now, the prompt does say to enter a
> *remote* shell path, so if I enter a local path, I made a mistake.
> However, the default shell path for `M-x shell' from a remote
> directory is a TRAMP path ("/sshx:server:/path/to/some//bin/sh"), so
> it's surprising that when I delete the TRAMP host prefix, I still end
> up running a shell on the remote server.
`read-file-name' as used in `shell' just reads a file name, no matter
whether a local or remote one.
> Perhaps it would be nicer if, when `M-x shell' prompted for the remote
> shell path, it didn't include the TRAMP prefix by default (e.g. the
> default value would just be "/bin/sh"). That might not interact well
> with `read-file-name' completion though; is it possible to use
> file-name completion on a remote path without the TRAMP prefix?
No, that doesn't work. File name completion and alike wouldn't work any
more.
But we could teach `read-file-name' to accept only remote file
names. What about this patch:
diff --git a/lisp/shell.el b/lisp/shell.el
index 62de5be817..4339e8c0a3 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -759,7 +759,8 @@ shell
(file-local-name
(expand-file-name
(read-file-name "Remote shell path: " default-directory
- shell-file-name t shell-file-name)))))
+ shell-file-name t shell-file-name
+ #'file-remote-p)))))
;; Rain or shine, BUFFER must be current by now.
(unless (comint-check-proc buffer)
It is not perfect, one can still enter "/sudo::/bin/sh" when
`default-directory' is "/ssh::". But I wouldn't count this as mistake,
it would be rather a "user error by intention" :-)
Best regards, Michael.