aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2018-06-22 16:17:17 +0200
committerMichael Albinus2018-06-22 16:17:17 +0200
commite6476c914ebd60971708e0ea0a292e1616d928fd (patch)
treefa48d959e9bf5c5d25559654cd03736634603638
parent4e15d263134fdb8c9ff75e70f3f86225ad32ad31 (diff)
downloademacs-e6476c914ebd60971708e0ea0a292e1616d928fd.tar.gz
emacs-e6476c914ebd60971708e0ea0a292e1616d928fd.zip
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.
-rw-r--r--lisp/net/tramp-adb.el2
-rw-r--r--lisp/net/tramp-sh.el27
-rw-r--r--test/lisp/net/tramp-tests.el20
3 files changed, 29 insertions, 20 deletions
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."
1130 (read (current-buffer))) 1130 (read (current-buffer)))
1131 ":" 'omit))) 1131 ":" 'omit)))
1132 ;; The equivalent to `exec-directory'. 1132 ;; The equivalent to `exec-directory'.
1133 `(,(file-local-name default-directory)))) 1133 `(,(file-remote-p default-directory 'localname))))
1134 1134
1135(defun tramp-adb-get-device (vec) 1135(defun tramp-adb-get-device (vec)
1136 "Return full host name from VEC to be used in shell execution. 1136 "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."
3089 (append 3089 (append
3090 (tramp-get-remote-path (tramp-dissect-file-name default-directory)) 3090 (tramp-get-remote-path (tramp-dissect-file-name default-directory))
3091 ;; The equivalent to `exec-directory'. 3091 ;; The equivalent to `exec-directory'.
3092 `(,(file-local-name default-directory)))) 3092 `(,(file-remote-p default-directory 'localname))))
3093 3093
3094(defun tramp-sh-handle-file-local-copy (filename) 3094(defun tramp-sh-handle-file-local-copy (filename)
3095 "Like `file-local-copy' for Tramp files." 3095 "Like `file-local-copy' for Tramp files."
@@ -5349,16 +5349,21 @@ Nonexistent directories are removed from spec."
5349 5349
5350(defun tramp-get-ls-command-with (vec option) 5350(defun tramp-get-ls-command-with (vec option)
5351 "Return OPTION, if the remote `ls' command supports the OPTION option." 5351 "Return OPTION, if the remote `ls' command supports the OPTION option."
5352 (save-match-data 5352 (with-tramp-connection-property vec (concat "ls" option)
5353 (with-tramp-connection-property vec (concat "ls" option) 5353 (tramp-message vec 5 "Checking, whether `ls %s' works" option)
5354 (tramp-message vec 5 "Checking, whether `ls %s' works" option) 5354 ;; Some "ls" versions are sensible wrt the order of arguments,
5355 ;; Some "ls" versions are sensible wrt the order of arguments, 5355 ;; they fail when "-al" is after the "--dired" argument (for
5356 ;; they fail when "-al" is after the "--dired" argument (for 5356 ;; example on FreeBSD). Busybox does not support this kind of
5357 ;; example on FreeBSD). 5357 ;; options.
5358 (and 5358 (and
5359 (tramp-send-command-and-check 5359 (not
5360 vec (format "%s %s -al /dev/null" (tramp-get-ls-command vec) option)) 5360 (tramp-send-command-and-check
5361 option)))) 5361 vec
5362 (format
5363 "%s ls --help 2>&1 | grep -iq busybox" (tramp-get-ls-command vec))))
5364 (tramp-send-command-and-check
5365 vec (format "%s %s -al /dev/null" (tramp-get-ls-command vec) option))
5366 option)))
5362 5367
5363(defun tramp-get-test-command (vec) 5368(defun tramp-get-test-command (vec)
5364 "Determine remote `test' command." 5369 "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'."
4021 (put 'explicit-shell-file-name 'permanent-local nil) 4021 (put 'explicit-shell-file-name 'permanent-local nil)
4022 (kill-buffer "*shell*")))) 4022 (kill-buffer "*shell*"))))
4023 4023
4024;; The function was introduced in Emacs 27.1. 4024;; `exec-path' was introduced in Emacs 27.1. `executable-find' has
4025;; changed the number of parameters, so we use `apply' for older
4026;; Emacsen.
4025(ert-deftest tramp-test34-exec-path () 4027(ert-deftest tramp-test34-exec-path ()
4026 "Check `exec-path' and `executable-find'." 4028 "Check `exec-path' and `executable-find'."
4027 (skip-unless (tramp--test-enabled)) 4029 (skip-unless (tramp--test-enabled))
4028 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) 4030 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
4029 ;; Since Emacs 27.1. 4031 ;; Since Emacs 27.1.
4030 (skip-unless (boundp 'exec-path)) 4032 (skip-unless (fboundp 'exec-path))
4031 4033
4032 (let ((tmp-name (tramp--test-make-temp-name)) 4034 (let ((tmp-name (tramp--test-make-temp-name))
4033 (default-directory tramp-test-temporary-file-directory)) 4035 (default-directory tramp-test-temporary-file-directory))
@@ -4038,9 +4040,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4038 (should 4040 (should
4039 (string-equal 4041 (string-equal
4040 (car (last (with-no-warnings (exec-path)))) 4042 (car (last (with-no-warnings (exec-path))))
4041 (file-local-name default-directory))) 4043 (file-remote-p default-directory 'localname)))
4042 ;; The shell "sh" shall always exist. 4044 ;; The shell "sh" shall always exist.
4043 (should (executable-find "sh" 'remote)) 4045 (should (apply 'executable-find '("sh" remote)))
4044 ;; Since the last element in `exec-path' is the current 4046 ;; Since the last element in `exec-path' is the current
4045 ;; directory, an executable file in that directory will be 4047 ;; directory, an executable file in that directory will be
4046 ;; found. 4048 ;; found.
@@ -4050,11 +4052,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4050 (should (file-executable-p tmp-name)) 4052 (should (file-executable-p tmp-name))
4051 (should 4053 (should
4052 (string-equal 4054 (string-equal
4053 (executable-find (file-name-nondirectory tmp-name) 'remote) 4055 (apply
4054 (file-local-name tmp-name))) 4056 'executable-find `(,(file-name-nondirectory tmp-name) remote))
4057 (file-remote-p tmp-name 'localname)))
4055 (should-not 4058 (should-not
4056 (executable-find 4059 (apply
4057 (concat (file-name-nondirectory tmp-name) "foo") 'remote))) 4060 'executable-find
4061 `(,(concat (file-name-nondirectory tmp-name) "foo") remote))))
4058 4062
4059 ;; Cleanup. 4063 ;; Cleanup.
4060 (ignore-errors (delete-file tmp-name))))) 4064 (ignore-errors (delete-file tmp-name)))))