From: Michael Albinus Date: Fri, 22 Jun 2018 14:17:17 +0000 (+0200) Subject: Improve backward compatibility of Tramp X-Git-Tag: emacs-27.0.90~4780 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e6476c914ebd60971708e0ea0a292e1616d928fd;p=emacs.git Improve backward compatibility of Tramp * 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. --- diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 7cb61adde80..297bdd712f6 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -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. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 0b3c12333f2..26bf3cd0c0c 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -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." diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index df07a8f1b89..f2d9b0ab47e 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -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)))))