From 966c4d3ba8896c86764bc8664ca43e04eadf711d Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 15 Jul 2019 11:11:59 +0200 Subject: [PATCH] Fix edge cases in Tramp's copy * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): Special handling for "rsync". (tramp-find-inline-compress): Make check more robust on MS Windows. --- lisp/net/tramp-sh.el | 50 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ee0754fee94..9a0ead47552 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -266,11 +266,13 @@ The string is used in `tramp-methods'.") (add-to-list 'tramp-methods '("sudo" (tramp-login-program "sudo") - ;; The password template must be masked. Otherwise, it could be - ;; interpreted as password prompt if the remote host echoes the command. + ;; The password template must be masked. Otherwise, + ;; it could be interpreted as password prompt if the + ;; remote host echoes the command. (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":"))) - ;; Local $SHELL could be a nasty one, like zsh or fish. Let's override it. + ;; Local $SHELL could be a nasty one, like zsh or + ;; fish. Let's override it. (tramp-login-env (("SHELL") ("/bin/sh"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-login ("-l")) @@ -2304,7 +2306,8 @@ The method used must be an out-of-band method." ;; Check which ones of source and target are Tramp files. (setq source (funcall - (if (and (file-directory-p filename) + (if (and (string-equal method "rsync") + (file-directory-p filename) (not (file-exists-p newname))) #'file-name-as-directory #'identity) @@ -4557,25 +4560,24 @@ Goes through the list `tramp-inline-compress-commands'." "Checking local compress commands `%s', `%s' for sanity" compress decompress) (with-temp-buffer - (unless - (and - (zerop - (tramp-call-local-coding-command - (format - "echo %s | %s | %s" magic - ;; Windows shells need the program file name after - ;; the pipe symbol be quoted if they use forward - ;; slashes as directory separators. - (mapconcat - #'tramp-unquote-shell-quote-argument - (split-string compress) " ") - (mapconcat - #'tramp-unquote-shell-quote-argument - (split-string decompress) " ")) - nil t)) - (string-match - (concat "^" (regexp-quote magic) "$") (buffer-string))) - (throw 'next nil))) + (unless (zerop + (tramp-call-local-coding-command + (format + "echo %s | %s | %s" magic + ;; Windows shells need the program file name + ;; after the pipe symbol be quoted if they use + ;; forward slashes as directory separators. + (mapconcat + #'tramp-unquote-shell-quote-argument + (split-string compress) " ") + (mapconcat + #'tramp-unquote-shell-quote-argument + (split-string decompress) " ")) + nil t)) + (throw 'next nil)) + (goto-char (point-min)) + (unless (looking-at-p (regexp-quote magic)) + (throw 'next nil))) (tramp-message vec 5 "Checking remote compress commands `%s', `%s' for sanity" @@ -4585,7 +4587,7 @@ Goes through the list `tramp-inline-compress-commands'." (throw 'next nil)) (with-current-buffer (tramp-get-buffer vec) (goto-char (point-min)) - (unless (looking-at (regexp-quote magic)) + (unless (looking-at-p (regexp-quote magic)) (throw 'next nil))) (setq found t))) -- 2.39.2