branch: externals/tramp
commit 8283083697197d4f6e36c265253471441350892d
Author: Michael Albinus <[email protected]>
Commit: Michael Albinus <[email protected]>
Tramp ELPA version 2.8.1.5 released
---
README | 6 +++---
test/tramp-tests.el | 60 +++++++++++++++++++++++++++++++++++++++--------------
texi/tramp.texi | 15 ++++++++++++++
texi/trampver.texi | 2 +-
tramp-cmds.el | 2 +-
tramp-sh.el | 35 +++++++++++++++++++++++++++++++
tramp.el | 23 +++++++++++++++++---
trampver.el | 6 +++---
8 files changed, 123 insertions(+), 26 deletions(-)
diff --git a/README b/README
index b92dd8a2d4..945208d1fd 100644
--- a/README
+++ b/README
@@ -32,11 +32,11 @@ Emacs 28 or older
• Remove all byte-compiled Tramp files
- $ rm -f ~/.emacs.d/elpa/tramp-2.8.1.4/tramp*.elc
+ $ rm -f ~/.emacs.d/elpa/tramp-2.8.1.5/tramp*.elc
• Start Emacs with Tramp's source files
- $ emacs -L ~/.emacs.d/elpa/tramp-2.8.1.4 -l tramp
+ $ emacs -L ~/.emacs.d/elpa/tramp-2.8.1.5 -l tramp
This should not give you the error.
@@ -50,7 +50,7 @@ Mitigation of a bug in Emacs 29.1
---------------------------------
Due to a bug in Emacs 29.1, you must apply the following change prior
-installation or upgrading Tramp 2.8.1.4 from GNU ELPA:
+installation or upgrading Tramp 2.8.1.5 from GNU ELPA:
(when (string-equal emacs-version "29.1")
(with-current-buffer
diff --git a/test/tramp-tests.el b/test/tramp-tests.el
index a19a17dcec..4d11faf64d 100644
--- a/test/tramp-tests.el
+++ b/test/tramp-tests.el
@@ -117,9 +117,10 @@
(t (add-to-list
'tramp-methods
`("mock"
- (tramp-login-program ,tramp-default-remote-shell)
+ (tramp-login-program ,tramp-encoding-shell)
(tramp-login-args (("-i")))
(tramp-direct-async ("-c"))
+ (tramp-tmpdir ,temporary-file-directory)
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-args ("-c"))
(tramp-connection-timeout 10)))
@@ -219,16 +220,14 @@
'(fset 'tramp-gvfs-handler-askquestion
(lambda (_message _choices) '(t nil 0)))))
-(defconst tramp-test-vec
- (and (file-remote-p ert-remote-temporary-file-directory)
- (tramp-dissect-file-name ert-remote-temporary-file-directory))
- "The used `tramp-file-name' structure.")
-
(setq auth-source-cache-expiry nil
auth-source-save-behavior nil
auto-revert-remote-files t
auto-revert-use-notify t
ert-batch-backtrace-right-margin nil
+ ert-remote-temporary-file-directory
+ (let ((tramp-show-ad-hoc-proxies t) (non-essential t))
+ (expand-file-name ert-remote-temporary-file-directory))
password-cache-expiry nil
remote-file-name-inhibit-cache nil
tramp-allow-unsafe-temporary-files t
@@ -239,6 +238,11 @@
tramp-verbose 0
vc-handled-backends (unless noninteractive vc-handled-backends))
+(defconst tramp-test-vec
+ (and (file-remote-p ert-remote-temporary-file-directory)
+ (tramp-dissect-file-name ert-remote-temporary-file-directory))
+ "The used `tramp-file-name' structure.")
+
(defconst tramp-test-name-prefix "tramp-test"
"Prefix to use for temporary test files.")
@@ -6517,13 +6521,12 @@ INPUT, if non-nil, is a string sent to the process."
;; (should (= 11 (point)))))))))))))
)))))))))
-;; This test is inspired by Bug#23952.
+;; This test is inspired by Bug#23952 and Bug#80783.
(ert-deftest tramp-test33-environment-variables ()
"Check that remote processes set / unset environment variables properly."
:tags '(:expensive-test)
(skip-unless (tramp--test-enabled))
- (skip-unless (tramp--test-sh-p))
- (skip-unless (not (tramp--test-crypt-p)))
+ (skip-unless (tramp--test-supports-environment-variables-p))
(dolist (this-shell-command-to-string
(append
@@ -6553,6 +6556,21 @@ INPUT, if non-nil, is a string sent to the process."
(funcall
this-shell-command-to-string "echo \"${INSIDE_EMACS:-bla}\""))))
+ ;; Check EMACSCLIENT_TRAMP.
+ (setenv "EMACSCLIENT_TRAMP")
+ (let ((tramp-propagate-emacsclient-tramp t))
+ (should
+ (string-equal
+ (format "%s\n" (tramp-make-tramp-file-name tramp-test-vec 'noloc))
+ (funcall
+ this-shell-command-to-string "echo \"${EMACSCLIENT_TRAMP:-bla}\""))))
+ (let (tramp-propagate-emacsclient-tramp)
+ (should
+ (string-equal
+ "bla\n"
+ (funcall
+ this-shell-command-to-string "echo \"${EMACSCLIENT_TRAMP:-bla}\""))))
+
;; Set a value.
(let ((process-environment
(cons (concat envvar "=foo") process-environment)))
@@ -6609,7 +6627,18 @@ INPUT, if non-nil, is a string sent to the process."
;; We must suppress "_=VAR...".
(funcall
this-shell-command-to-string
- "printenv | grep -v PS1 | grep -v _=")))))))))
+ "printenv | grep -v PS1 | grep -v _="))))))
+
+ ;; Handle looooong environment variables. Bug#80783.
+ ;; FIXME: Make it also work in the synchronous case.
+ (unless (or (eq this-shell-command-to-string 'shell-command-to-string)
+ (tramp-direct-async-process-p))
+ (let* ((bad (concat envvar "=" (make-string 2024 ?x)))
+ (process-environment
+ (cl-list* bad bad bad bad process-environment)))
+ (should
+ (string-match-p
+ "foo" (funcall this-shell-command-to-string "echo foo"))))))))
(tramp--test-deftest-direct-async-process tramp-test33-environment-variables)
@@ -6828,8 +6857,7 @@ INPUT, if non-nil, is a string sent to the process."
"Check loooong `tramp-remote-path'."
:tags '(:expensive-test)
(skip-unless (tramp--test-enabled))
- (skip-unless (tramp--test-sh-p))
- (skip-unless (not (tramp--test-crypt-p)))
+ (skip-unless (tramp--test-supports-environment-variables-p))
(let* ((tmp-name1 (tramp--test-make-temp-name))
(default-directory ert-remote-temporary-file-directory)
@@ -7769,6 +7797,11 @@ This requires restrictions of file name syntax."
(tramp--test-sh-p) (tramp--test-smb-p)
(tramp--test-sudoedit-p)))
+(defun tramp--test-supports-environment-variables-p ()
+ "Return whether setting environment variables is supported."
+ (and (tramp--test-sh-p)
+ (not (tramp--test-crypt-p))))
+
(defun tramp--test-check-files (&rest files)
"Run a simple but comprehensive test over every file in FILES."
(dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
@@ -9298,9 +9331,6 @@ If INTERACTIVE is non-nil, the tests are run
interactively."
;; Use `skip-when' starting with Emacs 30.1.
-;; Starting with Emacs 29, use `ert-with-temp-file' and
-;; `ert-with-temp-directory'.
-
(provide 'tramp-tests)
;;; tramp-tests.el ends here
diff --git a/texi/tramp.texi b/texi/tramp.texi
index 79271d2ef5..8d3d5dd287 100644
--- a/texi/tramp.texi
+++ b/texi/tramp.texi
@@ -4227,6 +4227,14 @@ called is local or remote, since @value{tramp} would add
just the
@env{HGPLAIN} setting and local processes would take whole value of
@code{process-environment} along with the new value of @env{HGPLAIN}.
+@vindex tramp-propagate-emacsclient-tramp
+@vindex EMACSCLIENT_TRAMP@r{, environment variable}
+If you set the user option @code{tramp-propagate-emacsclient-tramp} to
+a non-@code{nil} value, the environment variable
+@env{EMACSCLIENT_TRAMP} will be set to a value which allows to call
+@command{emacsclient} from a process running on the remote
+host. @xref{emacsclient Options, , , emacs}.
+
For integrating other Emacs packages so @value{tramp} can execute
remotely, please file a bug report. @xref{Bug Reports}.
@@ -6427,6 +6435,13 @@ You can change this directory by setting the user option
"XDG_RUNTIME_DIR")}.
+@item
+I get an error @samp{Method `gdrive' not supported by GVFS}.
+
+@samp{google-drive} has been disabled in @acronym{GNOME} 50. It is
+not clear yet whether and when it will be reenabled.
+@c @uref{https://discourse.gnome.org/t/google-drive-in-gnome-50/34417}
+
@item
How to ignore errors when changing file attributes?
diff --git a/texi/trampver.texi b/texi/trampver.texi
index cf3fd7a824..0b2ef864cc 100644
--- a/texi/trampver.texi
+++ b/texi/trampver.texi
@@ -7,7 +7,7 @@
@c In the Tramp GIT, the version number and the bug report address
@c are auto-frobbed from configure.ac.
-@set trampver 2.8.1.4
+@set trampver 2.8.1.5
@set trampurl https://www.gnu.org/software/tramp/
@set tramp-bug-report-address tramp-devel@@gnu.org
@set emacsver 28.1
diff --git a/tramp-cmds.el b/tramp-cmds.el
index 95e1c5ecad..1fc77f0e80 100644
--- a/tramp-cmds.el
+++ b/tramp-cmds.el
@@ -63,7 +63,7 @@ SYNTAX can be one of the symbols `default' (default),
(interactive
(list
(completing-read
- "method: "
+ "Method: "
(tramp-compat-seq-keep
(lambda (x)
(when-let* ((name (symbol-name x))
diff --git a/tramp-sh.el b/tramp-sh.el
index 8cade9ce09..8d4dc55767 100644
--- a/tramp-sh.el
+++ b/tramp-sh.el
@@ -3091,8 +3091,27 @@ will be used."
(if (string-search "=" elt)
(setq env (append env `(,elt)))
(setq uenv (cons elt uenv))))))
+ (env (if tramp-propagate-emacsclient-tramp
+ (setenv-internal
+ env "EMACSCLIENT_TRAMP"
+ (tramp-make-tramp-file-name v 'noloc) 'keep)
+ env))
(env (setenv-internal
env "INSIDE_EMACS" (tramp-inside-emacs) 'keep))
+ ;; Environment is too large. Keep it here.
+ (eenv (and (> (apply #'+ (length env) (seq-map #'length env)) 2000)
+ env))
+ (env (if (not eenv) env
+ `(,(concat
+ "INSIDE_EMACS=" (getenv-internal "INSIDE_EMACS" env))
+ ,(concat "PS1=" (getenv-internal "PS1" env)))))
+ (eenv (setenv-internal eenv "INSIDE_EMACS" nil nil))
+ (eenv (setenv-internal eenv "PS1" nil nil))
+ vars
+ (eenv (dolist (item (reverse eenv) vars)
+ (setq item (split-string item "=" 'omit))
+ (setcdr item (string-join (cdr item) "="))
+ (push (format "%s %s" (car item) (cdr item)) vars)))
(command
(when (stringp program)
(format "cd %s && %s exec %s %s env %s %s"
@@ -3207,6 +3226,16 @@ will be used."
(widen)
(delete-region mark (point-max))
(narrow-to-region (point-max) (point-max))
+ ;; Send delayed environment.
+ (when eenv
+ (tramp-send-command
+ v
+ (format
+ "while read var val; do export $var=\"$val\"; done
<<'%s'\n%s\n%s"
+ tramp-end-of-heredoc
+ (string-join eenv "\n")
+ tramp-end-of-heredoc)
+ t))
;; Now do it.
(if command
;; Send the command.
@@ -3326,7 +3355,13 @@ will be used."
(if (string-search "=" elt)
(setq env (append env `(,elt)))
(setq uenv (cons elt uenv)))))
+ (when tramp-propagate-emacsclient-tramp
+ (setq env (setenv-internal
+ env "EMACSCLIENT_TRAMP"
+ (tramp-make-tramp-file-name v 'noloc) 'keep)))
(setq env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs)
'keep))
+ ;; Remove looong environment variables, for example from tramp-tests.el.
+ (setq env (seq-remove (lambda (x) (length> x 256)) env))
(when env
(setq command
(format
diff --git a/tramp.el b/tramp.el
index 5705a2bc0b..4988883f91 100644
--- a/tramp.el
+++ b/tramp.el
@@ -7,7 +7,7 @@
;; Maintainer: Michael Albinus <[email protected]>
;; Keywords: comm, processes
;; Package: tramp
-;; Version: 2.8.1.4
+;; Version: 2.8.1.5
;; Package-Requires: ((emacs "28.1"))
;; Package-Type: multi
;; URL: https://www.gnu.org/software/tramp/
@@ -1528,12 +1528,21 @@ The PATH environment variable should be set via
`tramp-remote-path'.
The TERM environment variable should be set via `tramp-terminal-type'.
+The EMACSCLIENT_TRAMP environment variable will be set accordingly, if
+`tramp-propagate-emacsclient-tramp' is non-nil.
+
The INSIDE_EMACS environment variable will automatically be set
based on the Tramp and Emacs versions, and should not be set here."
:version "26.1"
:type '(repeat string)
:link '(info-link :tag "Tramp manual" "(tramp) Remote processes"))
+(defcustom tramp-propagate-emacsclient-tramp nil
+ "Whether to propagate the EMACSCLIENT_TRAMP environment variable."
+ :version "31.1"
+ :type 'boolean
+ :link '(info-link :tag "Tramp manual" "(tramp) Remote processes"))
+
;;; Internal Variables:
;;;###tramp-autoload
@@ -2428,7 +2437,7 @@ arguments to pass to the OPERATION."
An entry has the form `(OPERATION . ARG-TYPE)'. ARG-TYPE can be the
symbol
-- `file': the first argument of OERATION is the remote file name to be
+- `file': the first argument of OPERATION is the remote file name to be
checked.
- `default-directory': `default-directory' is the remote file name to be
checked.
@@ -5509,6 +5518,13 @@ processes."
(env (if sh-file-name-handler-p
(setenv-internal env "TERM" tramp-terminal-type 'keep)
env))
+ ;; Add EMACSCLIENT_TRAMP.
+ (env (if (and tramp-propagate-emacsclient-tramp
+ sh-file-name-handler-p)
+ (setenv-internal
+ env "EMACSCLIENT_TRAMP"
+ (tramp-make-tramp-file-name v 'noloc) 'keep)
+ env))
;; Add INSIDE_EMACS.
(env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep))
(env (mapcar #'tramp-shell-quote-argument (delq nil env)))
@@ -7390,7 +7406,8 @@ T1 and T2 are time values (as returned by `current-time'
for example)."
Suppress `shell-file-name'. This is needed on w32 systems, which
would use a wrong quoting for local file names. See `w32-shell-name'."
(let (shell-file-name)
- (shell-quote-argument (file-name-unquote s))))
+ ;; Do not expand remote file names w/o a localname.
+ (shell-quote-argument (file-name-unquote s 'top))))
;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
;; does not deal well with newline characters. Newline is replaced by
diff --git a/trampver.el b/trampver.el
index d1c2533e3d..6b7ce5df2f 100644
--- a/trampver.el
+++ b/trampver.el
@@ -7,7 +7,7 @@
;; Maintainer: Michael Albinus <[email protected]>
;; Keywords: comm, processes
;; Package: tramp
-;; Version: 2.8.1.4
+;; Version: 2.8.1.5
;; Package-Requires: ((emacs "28.1"))
;; Package-Type: multi
;; URL: https://www.gnu.org/software/tramp/
@@ -40,7 +40,7 @@
;; ./configure" to change them.
;;;###tramp-autoload
-(defconst tramp-version "2.8.1.4"
+(defconst tramp-version "2.8.1.5"
"This version of Tramp.")
;;;###tramp-autoload
@@ -76,7 +76,7 @@
;; Check for Emacs version.
(let ((x (if (not (string-version-lessp emacs-version "28.1"))
"ok"
- (format "Tramp 2.8.1.4 is not fit for %s"
+ (format "Tramp 2.8.1.5 is not fit for %s"
(replace-regexp-in-string "\n" "" (emacs-version))))))
(unless (string-equal "ok" x) (error "%s" x)))