emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master fb39d31 1/2: Fix quoting problem in Tramp on w32 sy


From: Michael Albinus
Subject: [Emacs-diffs] master fb39d31 1/2: Fix quoting problem in Tramp on w32 systems
Date: Mon, 10 Jun 2019 11:53:27 -0400 (EDT)

branch: master
commit fb39d31e45ec766421f3ba3e5792b5f0365741c2
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Fix quoting problem in Tramp on w32 systems
    
    * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-profile):
    * lisp/net/tramp-integration.el (tramp-connection-local-default-profile):
    Revert patch from 2019-05-24.  It is fixed differently.
    
    * lisp/net/tramp.el (tramp-encoding-shell):
    (tramp-encoding-command-switch)
    (tramp-encoding-command-interactive, )
    (tramp-unquote-shell-quote-argument): Suppress `shell-file-name'.
    (tramp-set-file-uid-gid):
    * lisp/net/tramp-sh.el (tramp-find-inline-compress)
    (tramp-make-copy-program-file-name):
    * lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory):
    Use `tramp-unquote-shell-quote-argument'.
---
 lisp/net/tramp-adb.el         |  7 ++-----
 lisp/net/tramp-integration.el |  7 ++-----
 lisp/net/tramp-sh.el          | 11 +++++++----
 lisp/net/tramp-smb.el         |  6 ++++--
 lisp/net/tramp.el             | 25 +++++++++++++++++--------
 5 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 9a214c3..008a5ce 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1294,11 +1294,8 @@ connection if a previous connection has died for some 
reason."
 
 ;; Default settings for connection-local variables.
 (defconst tramp-adb-connection-local-default-profile
-  ;; `w32-shell-name' is derived from `shell-file-name'.  Don't let it
-  ;; be confused.
-  (unless (eq system-type 'windows-nt)
-    '((shell-file-name . "/system/bin/sh")
-      (shell-command-switch . "-c")))
+  '((shell-file-name . "/system/bin/sh")
+    (shell-command-switch . "-c"))
   "Default connection-local variables for remote adb connections.")
 
 ;; `connection-local-set-profile-variables' and
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index 6e3b027..35d2eb3 100644
--- a/lisp/net/tramp-integration.el
+++ b/lisp/net/tramp-integration.el
@@ -174,11 +174,8 @@ NAME must be equal to `tramp-current-connection'."
 ;;; Default connection-local variables for Tramp:
 
 (defconst tramp-connection-local-default-profile
-  ;; `w32-shell-name' is derived from `shell-file-name'.  Don't let it
-  ;; be confused.
-  (unless (eq system-type 'windows-nt)
-    '((shell-file-name . "/bin/sh")
-      (shell-command-switch . "-c")))
+  '((shell-file-name . "/bin/sh")
+    (shell-command-switch . "-c"))
   "Default connection-local variables for remote connections.")
 
 ;; `connection-local-set-profile-variables' and
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 34fda5a..3d572ad 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -4578,9 +4578,11 @@ Goes through the list `tramp-inline-compress-commands'."
                 ;; the pipe symbol be quoted if they use forward
                 ;; slashes as directory separators.
                 (mapconcat
-                 #'shell-quote-argument (split-string compress) " ")
+                 #'tramp-unquote-shell-quote-argument
+                 (split-string compress) " ")
                 (mapconcat
-                 #'shell-quote-argument (split-string decompress) " "))
+                 #'tramp-unquote-shell-quote-argument
+                 (split-string decompress) " "))
                nil nil))
            (throw 'next nil))
          (tramp-message
@@ -5282,8 +5284,9 @@ Return ATTR."
      ((tramp-get-method-parameter vec 'tramp-remote-copy-program)
       localname)
      ((not (zerop (length user)))
-      (format "%s@%s:%s" user host (shell-quote-argument localname)))
-     (t (format "%s:%s" host (shell-quote-argument localname))))))
+      (format
+       "%s@%s:%s" user host (tramp-unquote-shell-quote-argument localname)))
+     (t (format "%s:%s" host (tramp-unquote-shell-quote-argument 
localname))))))
 
 (defun tramp-method-out-of-band-p (vec size)
   "Return t if this is an out-of-band method, nil otherwise."
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 84725db..37c40a0 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -468,7 +468,8 @@ pass to the OPERATION."
                        (append args
                                (list "-D" (tramp-unquote-shell-quote-argument
                                            localname)
-                                     "-c" (shell-quote-argument "tar qc - *")
+                                     "-c" (tramp-unquote-shell-quote-argument
+                                           "tar qc - *")
                                      "|" "tar" "xfC" "-"
                                      (tramp-unquote-shell-quote-argument
                                       tmpdir)))
@@ -479,7 +480,8 @@ pass to the OPERATION."
                              args
                              (list "-D" (tramp-unquote-shell-quote-argument
                                          localname)
-                                   "-c" (shell-quote-argument "tar qx -")))))
+                                   "-c" (tramp-unquote-shell-quote-argument
+                                         "tar qx -")))))
 
              (unwind-protect
                  (with-temp-buffer
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index f6dd6b5..76eb03b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -135,8 +135,10 @@ This setting has precedence over 
`auto-save-file-name-transforms'."
   :type '(choice (const :tag "Use default" nil)
                 (directory :tag "Auto save directory name")))
 
+;; Suppress `shell-file-name' for w32 systems.
 (defcustom tramp-encoding-shell
-  (or (tramp-compat-funcall 'w32-shell-name) "/bin/sh")
+  (let (shell-file-name)
+    (or (tramp-compat-funcall 'w32-shell-name) "/bin/sh"))
   "Use this program for encoding and decoding commands on the local host.
 This shell is used to execute the encoding and decoding command on the
 local host, so if you want to use `~' in those commands, you should
@@ -159,15 +161,19 @@ use for the remote host."
   :group 'tramp
   :type '(file :must-match t))
 
+;; Suppress `shell-file-name' for w32 systems.
 (defcustom tramp-encoding-command-switch
-  (if (tramp-compat-funcall 'w32-shell-dos-semantics) "/c" "-c")
+  (let (shell-file-name)
+    (if (tramp-compat-funcall 'w32-shell-dos-semantics) "/c" "-c"))
   "Use this switch together with `tramp-encoding-shell' for local commands.
 See the variable `tramp-encoding-shell' for more information."
   :group 'tramp
   :type 'string)
 
+;; Suppress `shell-file-name' for w32 systems.
 (defcustom tramp-encoding-command-interactive
-  (unless (tramp-compat-funcall 'w32-shell-dos-semantics) "-i")
+  (let (shell-file-name)
+    (unless (tramp-compat-funcall 'w32-shell-dos-semantics) "-i"))
   "Use this switch together with `tramp-encoding-shell' for interactive shells.
 See the variable `tramp-encoding-shell' for more information."
   :version "24.1"
@@ -4391,13 +4397,13 @@ If FILENAME is remote, a file name handler is called."
   (let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid)))
     (if handler
        (funcall handler #'tramp-set-file-uid-gid filename uid gid)
-      ;; On W32 "chown" does not work.
+      ;; On W32 systems, "chown" does not work.
       (unless (memq system-type '(ms-dos windows-nt))
        (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
              (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
          (tramp-call-process
-          nil "chown" nil nil nil
-          (format "%d:%d" uid gid) (shell-quote-argument filename)))))))
+          nil "chown" nil nil nil (format "%d:%d" uid gid)
+          (tramp-unquote-shell-quote-argument filename)))))))
 
 (defun tramp-get-local-uid (id-format)
   "The uid of the local user, in ID-FORMAT.
@@ -4815,8 +4821,11 @@ T1 and T2 are time values (as returned by `current-time' 
for example)."
   (float-time (time-subtract t1 t2)))
 
 (defun tramp-unquote-shell-quote-argument (s)
-  "Remove quotation prefix \"/:\" from string S, and quote it then for shell."
-  (shell-quote-argument (tramp-compat-file-name-unquote s)))
+  "Remove quotation prefix \"/:\" from string S, and quote it then for shell.
+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 (tramp-compat-file-name-unquote s))))
 
 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
 ;; does not deal well with newline characters.  Newline is replaced by



reply via email to

[Prev in Thread] Current Thread [Next in Thread]