aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-04-17 14:04:37 +0200
committerMichael Albinus2019-04-17 14:04:37 +0200
commit2c06731dca42ee4f10484a6c72b3528e14c548d7 (patch)
treeb504a55790771a9eaa08e5c7b55c5b4902e9687b
parent48a6a3ac028181dbe32f6619982539adb0cd9a6a (diff)
downloademacs-2c06731dca42ee4f10484a6c72b3528e14c548d7.tar.gz
emacs-2c06731dca42ee4f10484a6c72b3528e14c548d7.zip
Fix Bug#35241
* lisp/files.el (executable-find): Quote default-directory. (Bug#35241) * test/lisp/files-tests.el (files-tests-executable-find): New test.
-rw-r--r--lisp/files.el3
-rw-r--r--test/lisp/files-tests.el26
2 files changed, 28 insertions, 1 deletions
diff --git a/lisp/files.el b/lisp/files.el
index b81550e297c..c05d70a00ec 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1058,7 +1058,8 @@ REMOTE is non-nil, search on the remote host indicated by
1058 (when (stringp res) (file-local-name res))) 1058 (when (stringp res) (file-local-name res)))
1059 ;; Use 1 rather than file-executable-p to better match the 1059 ;; Use 1 rather than file-executable-p to better match the
1060 ;; behavior of call-process. 1060 ;; behavior of call-process.
1061 (locate-file command exec-path exec-suffixes 1))) 1061 (let ((default-directory (file-name-quote default-directory 'top)))
1062 (locate-file command exec-path exec-suffixes 1))))
1062 1063
1063(defun load-library (library) 1064(defun load-library (library)
1064 "Load the Emacs Lisp library named LIBRARY. 1065 "Load the Emacs Lisp library named LIBRARY.
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 13e8bb4943c..53e6e9064a1 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1218,5 +1218,31 @@ See <https://debbugs.gnu.org/19657#20>."
1218 process-environment))) 1218 process-environment)))
1219 (should (equal old (file-truename (abbreviate-file-name testfile)))))) 1219 (should (equal old (file-truename (abbreviate-file-name testfile))))))
1220 1220
1221(ert-deftest files-tests-executable-find ()
1222 "Test that `executable-find' works also with a relative or remote PATH.
1223See <https://debbugs.gnu.org/35241>."
1224 (let ((tmpfile (make-temp-file "files-test")))
1225 (unwind-protect
1226 (progn
1227 (set-file-modes tmpfile #o777)
1228 (let ((exec-path `(,temporary-file-directory)))
1229 (should
1230 (equal tmpfile
1231 (executable-find (file-name-nondirectory tmpfile)))))
1232 ;; An empty element of `exec-path' means `default-directory'.
1233 (let ((default-directory temporary-file-directory)
1234 (exec-path nil))
1235 (should
1236 (equal tmpfile
1237 (executable-find (file-name-nondirectory tmpfile)))))
1238 ;; The remote file name shall be quoted, and handled like a
1239 ;; non-existing directory.
1240 (let ((default-directory "/ssh::")
1241 (exec-path (append exec-path `("." ,temporary-file-directory))))
1242 (should
1243 (equal tmpfile
1244 (executable-find (file-name-nondirectory tmpfile))))))
1245 (delete-file tmpfile))))
1246
1221(provide 'files-tests) 1247(provide 'files-tests)
1222;;; files-tests.el ends here 1248;;; files-tests.el ends here