Commit 2c06731d authored by Michael Albinus's avatar Michael Albinus

Fix Bug#35241

* lisp/files.el (executable-find): Quote default-directory.  (Bug#35241)

* test/lisp/files-tests.el (files-tests-executable-find): New test.
parent 48a6a3ac
Pipeline #1324 failed with stage
in 52 minutes and 27 seconds
......@@ -1058,7 +1058,8 @@ REMOTE is non-nil, search on the remote host indicated by
(when (stringp res) (file-local-name res)))
;; Use 1 rather than file-executable-p to better match the
;; behavior of call-process.
(locate-file command exec-path exec-suffixes 1)))
(let ((default-directory (file-name-quote default-directory 'top)))
(locate-file command exec-path exec-suffixes 1))))
(defun load-library (library)
"Load the Emacs Lisp library named LIBRARY.
......
......@@ -1218,5 +1218,31 @@ See <https://debbugs.gnu.org/19657#20>."
process-environment)))
(should (equal old (file-truename (abbreviate-file-name testfile))))))
(ert-deftest files-tests-executable-find ()
"Test that `executable-find' works also with a relative or remote PATH.
See <https://debbugs.gnu.org/35241>."
(let ((tmpfile (make-temp-file "files-test")))
(unwind-protect
(progn
(set-file-modes tmpfile #o777)
(let ((exec-path `(,temporary-file-directory)))
(should
(equal tmpfile
(executable-find (file-name-nondirectory tmpfile)))))
;; An empty element of `exec-path' means `default-directory'.
(let ((default-directory temporary-file-directory)
(exec-path nil))
(should
(equal tmpfile
(executable-find (file-name-nondirectory tmpfile)))))
;; The remote file name shall be quoted, and handled like a
;; non-existing directory.
(let ((default-directory "/ssh::")
(exec-path (append exec-path `("." ,temporary-file-directory))))
(should
(equal tmpfile
(executable-find (file-name-nondirectory tmpfile))))))
(delete-file tmpfile))))
(provide 'files-tests)
;;; files-tests.el ends here
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