Commit e6476c91 authored by Michael Albinus's avatar Michael Albinus
Browse files

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.
parent 4e15d263
......@@ -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.
......
......@@ -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."
......
......@@ -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)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment