From: Jim Porter <jporterbugs@gmail.com>
To: 49229@debbugs.gnu.org
Subject: bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows
Date: Fri, 25 Jun 2021 16:05:57 -0700 [thread overview]
Message-ID: <CANh=_JECtqKvD3TBOwXGMqEMPLQLv9XHeaZ2rG7Qpxh=E6FA2w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2059 bytes --]
(Note: I primarily tested on 27.2, but this doesn't look to be any
different on 28.0.50.) When invoking `M-x shell' over TRAMP from a
local MS Windows system, the default remote shell path is corrupted:
emacs -Q
C-x C-f /sshx:server:~/some/file.txt
M-x shell
;; See the default prompt value:
;; /sshx:server:/path/to/some//bin/sh
;; ("/path/to/some/" is greyed out)
RET
The result is: "env: ‘c:/bin/sh’: No such file or directory". You can
also see this with the code used in `M-x shell' to get the remote
shell path:
(read-file-name
"Remote shell path: " default-directory shell-file-name
t shell-file-name)
Eval'ing that from a TRAMP buffer and hitting RET returns "/bin/sh"
(i.e. `shell-file-name'); that is, we lost the TRAMP prefix, even
though the prompt made it look like we'd keep it. If you edit the path
to, say, "/sshx:server:/path/to/some//usr/bin/zsh" and hit RET, the
result is "/sshx:server:/usr/bin/zsh", which is good. The result of
this call is then passed to `expand-file-name', which on MS Windows,
turns "/bin/sh" into "c:/bin/sh". Finally, that gets called on the
remote (running GNU/Linux), and things break.
I've attached a WIP patch that resolves this, but I don't think it's
quite right (hence, I didn't use `git format-patch'). This seems to be
more of an issue with `read-file-name' not being smart enough; even if
we set the `default-filename' argument to nil, the default return
value is still a local (non-TRAMP) path, which isn't right. Since
`read-file-name' is better able to tell whether the user wanted the
default value or they specifically wanted a local shell, it might be
better to fix the issue there. However, that's a pretty widely-used
function, and I'm hesitant to change the behavior in
potentially-breaking ways.
If the current WIP patch does look good though, I can clean it up (add
a comment and a commit message) for it to be merged. Or I can try to
fix `read-file-name' if there's agreement about how it should work in
this case.
[-- Attachment #2: shell-tramp.patch --]
[-- Type: application/octet-stream, Size: 1131 bytes --]
diff --git a/lisp/shell.el b/lisp/shell.el
index 62de5be817..e7369464fd 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -751,15 +751,16 @@ shell
(with-connection-local-variables
;; On remote hosts, the local `shell-file-name' might be useless.
- (when (and (file-remote-p default-directory)
- (called-interactively-p 'any)
- (null explicit-shell-file-name)
- (null (getenv "ESHELL")))
+ (when-let ((remote-host (file-remote-p default-directory))
+ ((called-interactively-p 'any))
+ ((null explicit-shell-file-name))
+ ((null (getenv "ESHELL"))))
(setq-local explicit-shell-file-name
(file-local-name
(expand-file-name
(read-file-name "Remote shell path: " default-directory
- shell-file-name t shell-file-name)))))
+ (concat remote-host shell-file-name) t
+ shell-file-name)))))
;; Rain or shine, BUFFER must be current by now.
(unless (comint-check-proc buffer)
next reply other threads:[~2021-06-25 23:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 23:05 Jim Porter [this message]
2021-06-26 14:33 ` bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows Michael Albinus
2021-06-26 18:01 ` Jim Porter
2021-06-27 8:41 ` Michael Albinus
2021-06-28 0:47 ` Jim Porter
2021-06-28 6:18 ` Michael Albinus
2021-07-01 17:07 ` Jim Porter
2021-07-02 12:58 ` Michael Albinus
2021-07-02 21:30 ` Jim Porter
2021-07-03 6:42 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANh=_JECtqKvD3TBOwXGMqEMPLQLv9XHeaZ2rG7Qpxh=E6FA2w@mail.gmail.com' \
--to=jporterbugs@gmail.com \
--cc=49229@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).