Commit ba59181c authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Fix problem with files like "~" in `directory-files-recursively'

* lisp/files.el (directory-files-recursively): Don't bug out on
files like "~" that have special meaning to `expand-file-name'
parent 9524e1f6
Pipeline #2359 passed with stage
in 59 minutes and 26 seconds
......@@ -819,8 +819,9 @@ order, and files from each directory are sorted in alphabetical order.
Each file name appears in the returned list in its absolute form.
Optional argument INCLUDE-DIRECTORIES non-nil means also include in the
output directories whose names match REGEXP."
(let ((result nil)
(let* ((result nil)
(files nil)
(dir (directory-file-name dir))
;; When DIR is "/", remote file names like "/method:" could
;; also be offered. We shall suppress them.
(tramp-mode (and tramp-mode (file-remote-p (expand-file-name dir)))))
......@@ -829,7 +830,7 @@ output directories whose names match REGEXP."
(unless (member file '("./" "../"))
(if (directory-name-p file)
(let* ((leaf (substring file 0 (1- (length file))))
(full-file (expand-file-name leaf dir)))
(full-file (concat dir "/" leaf)))
;; Don't follow symlinks to other directories.
(unless (file-symlink-p full-file)
(setq result
......@@ -839,7 +840,7 @@ output directories whose names match REGEXP."
(string-match regexp leaf))
(setq result (nconc result (list full-file)))))
(when (string-match regexp file)
(push (expand-file-name file dir) files)))))
(push (concat dir "/" file) files)))))
(nconc result (nreverse files))))
(defvar module-file-suffix)
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