Fix Bug#35241
* lisp/files.el (executable-find): Quote default-directory. (Bug#35241) * test/lisp/files-tests.el (files-tests-executable-find): New test.
This commit is contained in:
parent
48a6a3ac02
commit
2c06731dca
2 changed files with 28 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue