]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve backward compatibility of Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 22 Jun 2018 14:17:17 +0000 (16:17 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 22 Jun 2018 14:17:17 +0000 (16:17 +0200)
* lisp/net/tramp-adb.el (tramp-adb-handle-exec-path):
* lisp/net/tramp-sh.el (tramp-sh-handle-exec-path): Use ´file-remote-p'.
(tramp-get-ls-command-with): Handle busybox specially.

* test/lisp/net/tramp-tests.el (tramp-test34-exec-path): Check for
`fboundp'.  Use `file-remote-p'.  Hide compiler warning for older
Emacsen.

lisp/net/tramp-adb.el
lisp/net/tramp-sh.el
test/lisp/net/tramp-tests.el

index 7cb61adde80c8f4f260713e00fcd2f196a10bb16..297bdd712f643ac8a4bdc022f3ad973fcaa93bbd 100644 (file)
@@ -1130,7 +1130,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
          (read (current-buffer)))
        ":" 'omit)))
    ;; The equivalent to `exec-directory'.
-   `(,(file-local-name default-directory))))
+   `(,(file-remote-p default-directory 'localname))))
 
 (defun tramp-adb-get-device (vec)
   "Return full host name from VEC to be used in shell execution.
index 0b3c12333f2cb2de510f48fc80a9393e4df2caf7..26bf3cd0c0c30388bebebe3e462c87e523196010 100644 (file)
@@ -3089,7 +3089,7 @@ the result will be a local, non-Tramp, file name."
   (append
    (tramp-get-remote-path (tramp-dissect-file-name default-directory))
    ;; The equivalent to `exec-directory'.
-   `(,(file-local-name default-directory))))
+   `(,(file-remote-p default-directory 'localname))))
 
 (defun tramp-sh-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
@@ -5349,16 +5349,21 @@ Nonexistent directories are removed from spec."
 
 (defun tramp-get-ls-command-with (vec option)
   "Return OPTION, if the remote `ls' command supports the OPTION option."
-  (save-match-data
-    (with-tramp-connection-property vec (concat "ls" option)
-      (tramp-message vec 5 "Checking, whether `ls %s' works" option)
-      ;; Some "ls" versions are sensible wrt the order of arguments,
-      ;; they fail when "-al" is after the "--dired" argument (for
-      ;; example on FreeBSD).
-      (and
-       (tramp-send-command-and-check
-       vec (format "%s %s -al /dev/null" (tramp-get-ls-command vec) option))
-       option))))
+  (with-tramp-connection-property vec (concat "ls" option)
+    (tramp-message vec 5 "Checking, whether `ls %s' works" option)
+    ;; Some "ls" versions are sensible wrt the order of arguments,
+    ;; they fail when "-al" is after the "--dired" argument (for
+    ;; example on FreeBSD).  Busybox does not support this kind of
+    ;; options.
+    (and
+     (not
+      (tramp-send-command-and-check
+       vec
+       (format
+       "%s ls --help 2>&1 | grep -iq busybox" (tramp-get-ls-command vec))))
+     (tramp-send-command-and-check
+      vec (format "%s %s -al /dev/null" (tramp-get-ls-command vec) option))
+     option)))
 
 (defun tramp-get-test-command (vec)
   "Determine remote `test' command."
index df07a8f1b89d9b56ecf6455b12083fb520b36b6d..f2d9b0ab47ef2cd36b603fdb3582e58b3cf1bff3 100644 (file)
@@ -4021,13 +4021,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
       (put 'explicit-shell-file-name 'permanent-local nil)
       (kill-buffer "*shell*"))))
 
-;; The function was introduced in Emacs 27.1.
+;; `exec-path' was introduced in Emacs 27.1.  `executable-find' has
+;; changed the number of parameters, so we use `apply' for older
+;; Emacsen.
 (ert-deftest tramp-test34-exec-path ()
   "Check `exec-path' and `executable-find'."
   (skip-unless (tramp--test-enabled))
   (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
   ;; Since Emacs 27.1.
-  (skip-unless (boundp 'exec-path))
+  (skip-unless (fboundp 'exec-path))
 
   (let ((tmp-name (tramp--test-make-temp-name))
        (default-directory tramp-test-temporary-file-directory))
@@ -4038,9 +4040,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
          (should
           (string-equal
            (car (last (with-no-warnings (exec-path))))
-           (file-local-name default-directory)))
+           (file-remote-p default-directory 'localname)))
          ;; The shell "sh" shall always exist.
-         (should (executable-find "sh" 'remote))
+         (should (apply 'executable-find '("sh" remote)))
          ;; Since the last element in `exec-path' is the current
          ;; directory, an executable file in that directory will be
          ;; found.
@@ -4050,11 +4052,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
          (should (file-executable-p tmp-name))
          (should
           (string-equal
-           (executable-find (file-name-nondirectory tmp-name) 'remote)
-           (file-local-name tmp-name)))
+           (apply
+            'executable-find `(,(file-name-nondirectory tmp-name) remote))
+           (file-remote-p tmp-name 'localname)))
          (should-not
-          (executable-find
-           (concat (file-name-nondirectory tmp-name) "foo") 'remote)))
+          (apply
+           'executable-find
+           `(,(concat (file-name-nondirectory tmp-name) "foo") remote))))
 
       ;; Cleanup.
       (ignore-errors (delete-file tmp-name)))))