unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 49229@debbugs.gnu.org
Subject: bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows
Date: Sun, 27 Jun 2021 10:41:52 +0200	[thread overview]
Message-ID: <87czs7pulr.fsf@gmx.de> (raw)
In-Reply-To: <CANh=_JFiPJ1KXuDxskjBy8rQ5Jg+prEzgwhbf1P0M-HrHCGq9Q@mail.gmail.com> (Jim Porter's message of "Sat, 26 Jun 2021 11:01:41 -0700")

[-- Attachment #1: Type: text/plain, Size: 1504 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 602 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 208 bytes --]


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.

  reply	other threads:[~2021-06-27  8:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 23:05 bug#49229: 27.2; `M-x shell' fails over TRAMP from local MS Windows Jim Porter
2021-06-26 14:33 ` Michael Albinus
2021-06-26 18:01   ` Jim Porter
2021-06-27  8:41     ` Michael Albinus [this message]
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=87czs7pulr.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=49229@debbugs.gnu.org \
    --cc=jporterbugs@gmail.com \
    /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).