From e3edbf577b49bbff0527cd6f3242a98916947875 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 4 Aug 2022 18:12:25 +0200 Subject: [PATCH] Fix last Tramp change, especially for bug#56963 * lisp/net/tramp-adb.el (tramp-adb-handle-write-region): Add missing space. * lisp/net/tramp-sh.el (tramp-sh-handle-write-region): Use "cat", "echo -n" isn't portable. (Bug#56963) * lisp/net/tramp.el (tramp-file-name-unify): Unquote file name in time. --- lisp/net/tramp-adb.el | 2 +- lisp/net/tramp-sh.el | 4 +++- lisp/net/tramp.el | 12 ++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 1d35f2b2ff7..ef0cc2d66c6 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -521,7 +521,7 @@ Emacs dired can't find files." ;; file is created. Do it directly. (if (and (stringp start) (string-empty-p start)) (tramp-adb-send-command-and-check - v (format "echo -n \"\">%s" (tramp-shell-quote-argument localname))) + v (format "echo -n \"\" >%s" (tramp-shell-quote-argument localname))) (let ((tmpfile (tramp-compat-make-temp-file filename))) (when (and append (file-exists-p filename)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index d88e388cd56..9e5347252ad 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3340,7 +3340,9 @@ implementation will be used." ;; file is created. Do it directly. (if (and (stringp start) (string-empty-p start)) (tramp-send-command - v (format "echo -n \"\">%s" (tramp-shell-quote-argument localname))) + v (format "cat <%s >%s" + (tramp-get-remote-null-device v) + (tramp-shell-quote-argument localname))) ;; Short track: if we are on the local host, we can run directly. (if (and (tramp-local-host-p v) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 0446e5754ae..a35b9baaa8c 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1487,21 +1487,21 @@ If nil, return `tramp-default-port'." (put #'tramp-file-name-port-or-default 'tramp-suppress-trace t) ;;;###tramp-autoload -(defun tramp-file-name-unify (vec &optional file) +(defun tramp-file-name-unify (vec &optional localname) "Unify VEC by removing localname and hop from `tramp-file-name' structure. -If FILE is a string, set it as localname. +If LOCALNAME is a string, set it as localname. Objects returned by this function compare `equal' if they refer to the same connection. Make a copy in order to avoid side effects." (when (tramp-file-name-p vec) (setq vec (copy-tramp-file-name vec)) (setf (tramp-file-name-localname vec) - (and (stringp file) + (and (stringp localname) ;; FIXME: This is a sanity check. When this error ;; doesn't happen for a while, it can be removed. - (or (file-name-absolute-p file) + (or (file-name-absolute-p localname) (tramp-error - vec 'file-error "File `%s' must be absolute" file)) - (directory-file-name (tramp-compat-file-name-unquote file))) + vec 'file-error "File `%s' must be absolute" localname)) + (tramp-compat-file-name-unquote (directory-file-name localname))) (tramp-file-name-hop vec) nil)) vec) -- 2.39.2