From fe37e49a970b590f6643228899234628f5671a22 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 8 Feb 2022 15:45:09 +0100 Subject: [PATCH] Fix processes on remote default-directory with special characters * lisp/net/tramp.el (tramp-handle-make-process): Quote `localname'. * test/lisp/net/tramp-tests.el (tramp--test-check-files): Test also remote `default-directory' for processes. (Bug#53846) --- lisp/net/tramp.el | 4 +++- test/lisp/net/tramp-tests.el | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 6d8f267ddf4..05a80e1dcf5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4292,7 +4292,9 @@ substitution. SPEC-LIST is a list of char/value pairs used for (command (mapconcat #'tramp-shell-quote-argument command " ")) ;; Set cwd and environment variables. (command - (append `("cd" ,localname "&&" "(" "env") env `(,command ")")))) + (append + `("cd" ,(tramp-shell-quote-argument localname) "&&" "(" "env") + env `(,command ")")))) ;; Check for `tramp-sh-file-name-handler', because something ;; is different between tramp-sh.el, and tramp-adb.el or diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index a4f2fe9e0e2..d78e8815b25 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -6475,6 +6475,23 @@ This requires restrictions of file name syntax." (delete-file file3) (should-not (file-exists-p file3)))) + ;; Check, that a process runs on a remote + ;; `default-directory' with special characters. See + ;; Bug#53846. + (when (and (tramp--test-expensive-test-p) + (tramp--test-supports-processes-p)) + (let ((default-directory file1)) + (dolist (this-shell-command + (append + ;; Synchronously. + '(shell-command) + ;; Asynchronously. + (and (tramp--test-asynchronous-processes-p) + '(tramp--test-async-shell-command)))) + (with-temp-buffer + (funcall this-shell-command "cat -- *" (current-buffer)) + (should (string-equal elt (buffer-string))))))) + (delete-file file2) (should-not (file-exists-p file2)) (delete-directory file1) -- 2.39.5