bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29149: Tramp shell uses local shell setting in windows


From: Shuguang Sun
Subject: bug#29149: Tramp shell uses local shell setting in windows
Date: Sun, 5 Nov 2017 12:10:08 +0800

Hi,

The tramp shell uses local shell setting (explicit-shell-file-name and shell-file-name) in Windows. However, according to the documents, for example, in tramp-handle-shell-command:
;; We cannot use `shell-file-name' and `shell-command-switch',
;; they are variables of the local host.
Instead, it uses the arguments tramp-remote-shell and tramp-remote-shell-args from the variable tramp-methods.

Windows7,
GNU Emacs 27.0.50 (build 1, x86_64-w64-mingw32) of 2017-10-21
explicit-shell-file-name = nil
shell-file-name = "C:/Users/username/emacs/libexec/emacs/27.0.50/x86_64-w64-mingw32/cmdproxy.exe"

- Problem 1: tramp and dired-do-shell-command:  start: Unknown job: /b
Why "start /b" is called remote side?

When I run tramp (plink) and go to a remote buffer (dired mode), run dired-do-shell-command (!) on marked file (for example, /opt/bin/R CMD BATCH * &). It popup the buffer of * Async Shell Command *, and the command is not run but a message "start: Unknown job: /b" which looks it runs the windows-like command "start /b ..." on the remote shell.

A test without "&" (non-ascync):
11:07:06.340383 tramp-handle-insert-directory (0) # Opening directory /plink:address@hidden:/opt/user/test/...done
11:07:35.748442 tramp-send-command (6) # ( cd /opt/user/test/ && /bin/sh -c start\ /b\ /opt/bin/R\ CMD\ BATCH\ --no-restore\ --no-save\ \"coxph.r\" </dev/null; echo tramp_exit_status $? )
11:07:36.033413 tramp-wait-for-regexp (6) #
start: invalid option: --no-restore
Try `start --help' for more information.
tramp_exit_status 1

It doen't help if (setq explicit-shell-file-name "/bin/sh"). It looks like due to the construction of the command which concats shell-file-name and args even if it is for tramp and remote host.

- Problem 2: tramp and shell: env: c:/bin/sh : No such file or directory
where "c:/" comes? Does it comes from some feature of completion of read-file-name?

In a tramp dried buffer, call shell which suppose to raise the shell buffer on remote server. However, I got error messge in the * shell * buffer that "env: c:/bin/sh : No such file or directory". I don't know where the "c:/" comes from. When shell is called, it reads the remote path in the minibufer with promotes (for remote shell path) "/plink:address@hidden:/path/to/dired/C:/Users/username/emacs/libexec/emacs/27.0.50/x86_64-w64-mingw32/cmdproxy.exe", and I change it to "/plink:address@hidden:/bin/", and then I got error message above. Below is the tracking:

12:00:20.871919 tramp-send-command (6) # cd /opt/user/test/ &&  exec  env PS1\=/plink\:address@hidden:/opt/user/test/\ \#\$\  TERM\=emacs TERMCAP\=emacs\:co\#135\:tc\=unknown\: INSIDE_EMACS\=27.0.50\,comint c\:/bin/sh -i

"c\"/bin/sh" is because I change the remote path to /plink:address@hidden:/bin/ when it asked in the minibuffer.

It opens the shell remotely if (setq explicit-shell-file-name "/bin/sh").
11:50:36.476919 tramp-send-command (6) # cd /opt/user/test/ &&  exec  env PS1\=/plink\:address@hidden:/opt/user/test/\ \#\$\  TERM\=emacs TERMCAP\=emacs\:co\#135\:tc\=unknown\: INSIDE_EMACS\=27.0.50\,comint /bin/sh -i
The remote shell path is not asked in this case.
Shoud it get tramp-remote-shell from tramp-methods or remote-shell from tramp-connection-properties directly?

- Problem 3: as in problem 2, shell-file-name is used in the complete of promote for remote path. It should not do in this way because shell-file-name is for local.
It triggered lots of try in hos side for completion:
11:16:47.779920 tramp-send-command (6) # test -d /opt/bee/user/test/C\:/Users/username/emacs/libexec/emacs/27.0.50/x86_64-w64-mingw32 2>/dev/null; echo tramp_exit_status $?
I have set ido-mode or icomplete-mode to nil.

The only tramp setting I used:
  (push '("plink"
           (tramp-login-program        "plink")
           (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%h")))
           (tramp-remote-shell         "/bin/sh")
           (tramp-remote-shell-args    ("-c"))
           (tramp-copy-program         "pscp")
           (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-scp") ("-p" "%k") ("-q") ("-r")))
           (tramp-copy-keep-date t)
           (tramp-copy-recursive t)
           (tramp-default-port         22))
        tramp-methods)




Best Regards,
Shuguang Sun

reply via email to

[Prev in Thread] Current Thread [Next in Thread]