Subject: bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows

From: Michael Albinus <[email-masked]>
Date: Sat, 26 Jun 2021 16:33:23 +0200

Jim Porter <[email-masked]> writes:

Hi Jim,

> 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.

Thanks for this report.

Occasionally, I've seen this problem on MS Windows already. Since I
don't run anything on MS Windows unless for bug hunting, I couldn't
locate it yet. With your recipe, it's reproducible now. It's not related
to "M-x shell" only, but more general.

> 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.

I've pushed a fix to the master branches of Emacs and Tramp. Could you,
pls, check?

Best regards, Michael.