1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-30 08:09:04 +00:00

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'
(bug#36490).
This commit is contained in:
Lars Ingebrigtsen 2019-07-10 14:03:55 +02:00
parent 9524e1f6a6
commit ba59181c41

View File

@ -819,17 +819,18 @@ 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)
(files nil)
;; 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)))))
(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)))))
(dolist (file (sort (file-name-all-completions "" dir)
'string<))
(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)