From: Lars Ingebrigtsen Date: Wed, 10 Jul 2019 12:03:55 +0000 (+0200) Subject: Fix problem with files like "~" in `directory-files-recursively' X-Git-Tag: emacs-27.0.90~2018 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ba59181c41a4685b595200306c6585a004c41e26;p=emacs.git 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). --- diff --git a/lisp/files.el b/lisp/files.el index e8a44af8ea5..b2249bfcb48 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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)