diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2020-12-20 19:45:11 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2020-12-20 19:45:11 +0100 |
commit | ecb5ebf156280be1859f181208306e4c55af3e80 (patch) | |
tree | aa221c254ca6e9189143c5cb1d48d5b24607be95 /lisp/net/tramp.el | |
parent | 1a0a11f7d2d1dbecb9f754b1e129d50e489058e6 (diff) | |
download | emacs-ecb5ebf156280be1859f181208306e4c55af3e80.tar.gz emacs-ecb5ebf156280be1859f181208306e4c55af3e80.tar.bz2 emacs-ecb5ebf156280be1859f181208306e4c55af3e80.zip |
Improve make-process in Tramp
* doc/misc/tramp.texi (Remote processes): Remove INSIDE_EMACS
restriction.
(Frequently Asked Questions, External packages): Add indices.
* etc/NEWS: 'start-process-shell-command' and
'start-file-process-shell-command' do not support the old calling
conventions any longer.
* lisp/subr.el (start-process-shell-command)
(start-file-process-shell-command): Remove old calling conventions.
* lisp/net/tramp-compat.el (remote-file-error): Remove, it isn't
necessary.
* lisp/net/tramp.el (tramp-handle-make-process): Remove special shell
handling. Support environment variables.
* test/lisp/net/tramp-tests.el
(tramp--test--deftest-direct-async-process): Skip for mock method.
(tramp--test-async-shell-command): Suppress `shell-command-sentinel'.
(tramp-test32-shell-command, tramp-test33-environment-variables):
Adapt tests.
(tramp-test32-shell-command-direct-async)
(tramp-test33-environment-variables-direct-async): New tests.
Diffstat (limited to 'lisp/net/tramp.el')
-rw-r--r-- | lisp/net/tramp.el | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 6c1c09bc371..4d8118a728b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3790,23 +3790,31 @@ It does not support `:stderr'." (unless (or (null stderr) (bufferp stderr)) (signal 'wrong-type-argument (list #'bufferp stderr))) - ;; Quote shell command. - (when (and (= (length command) 3) - (stringp (nth 0 command)) - (string-match-p "sh$" (nth 0 command)) - (stringp (nth 1 command)) - (string-equal "-c" (nth 1 command)) - (stringp (nth 2 command))) - (setcar (cddr command) (tramp-shell-quote-argument (nth 2 command)))) - (let* ((buffer (if buffer (get-buffer-create buffer) ;; BUFFER can be nil. We use a temporary buffer. (generate-new-buffer tramp-temp-buffer-name))) + ;; We use as environment the difference to toplevel + ;; `process-environment'. + (env (mapcar + (lambda (elt) + (unless + (member + elt (default-toplevel-value 'process-environment)) + (when (string-match-p "=" elt) elt))) + process-environment)) + (env (setenv-internal + env "INSIDE_EMACS" + (concat (or (getenv "INSIDE_EMACS") emacs-version) + ",tramp:" tramp-version) + 'keep)) + (env (mapcar #'tramp-shell-quote-argument (delq nil env))) + ;; Quote command. + (command (mapconcat #'tramp-shell-quote-argument command " ")) + ;; Set cwd and environment variables. (command - (mapconcat - #'identity (append `("cd" ,localname "&&") command) " "))) + (append `("cd" ,localname "&&" "(" "env") env `(,command ")")))) ;; Check for `tramp-sh-file-name-handler', because something ;; is different between tramp-adb.el and tramp-sh.el. @@ -3861,7 +3869,7 @@ It does not support `:stderr'." (mapcar (lambda (x) (split-string x " ")) login-args)) p (make-process :name name :buffer buffer - :command (append `(,login-program) login-args `(,command)) + :command (append `(,login-program) login-args command) :coding coding :noquery noquery :connection-type connection-type :filter filter :sentinel sentinel :stderr stderr)) |