emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 2c06731: Fix Bug#35241


From: Michael Albinus
Subject: [Emacs-diffs] master 2c06731: Fix Bug#35241
Date: Wed, 17 Apr 2019 08:04:48 -0400 (EDT)

branch: master
commit 2c06731dca42ee4f10484a6c72b3528e14c548d7
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Fix Bug#35241
    
    * lisp/files.el (executable-find): Quote default-directory.  (Bug#35241)
    
    * test/lisp/files-tests.el (files-tests-executable-find): New test.
---
 lisp/files.el            |  3 ++-
 test/lisp/files-tests.el | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index b81550e..c05d70a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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.
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 13e8bb4..53e6e90 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]