]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix problem with relative directories in CDPATH
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 7 Aug 2021 10:50:56 +0000 (12:50 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 7 Aug 2021 10:50:56 +0000 (12:50 +0200)
* lisp/files.el (parse-colon-path): Allow relative directories
(like ".") in CDPATH (bug#49918).

lisp/files.el
test/lisp/files-tests.el

index c26079569156c65380b83401405eea4ac521b262..b58f90db48c49bdbfb9f910d54e20aec28ab75eb 100644 (file)
@@ -782,7 +782,10 @@ nil (meaning `default-directory') as the associated list element."
     (let ((spath (substitute-env-vars search-path)))
       (mapcar (lambda (f)
                 (if (equal "" f) nil
-                  (let ((dir (expand-file-name (file-name-as-directory f))))
+                  (let ((dir (file-name-as-directory f)))
+                    (when (file-name-absolute-p dir)
+                      ;; Expand "~".
+                      (setq dir (expand-file-name dir)))
                     ;; Previous implementation used `substitute-in-file-name'
                     ;; which collapse multiple "/" in front.  Do the same for
                     ;; backward compatibility.
index 640f7d8420ec681f30c7b7f47c40b7924e6d55c5..523f51e01944010b5c9974ad2c70f21783f330df 100644 (file)
@@ -1461,7 +1461,10 @@ See <https://debbugs.gnu.org/36401>."
       (should (equal (parse-colon-path "x:/foo//bar/baz")
                      '("x:/foo/bar/baz/")))
     (should (equal (parse-colon-path "/foo//bar/baz")
-                 '("/foo/bar/baz/")))))
+                   '("/foo/bar/baz/"))))
+
+  (should (equal (parse-colon-path ".:/tmp")
+                 '("./" "/tmp/"))))
 
 (ert-deftest files-test-magic-mode-alist-doctype ()
   "Test that DOCTYPE and variants put files in mhtml-mode."