Function: eshell-glob-entries
eshell-glob-entries is a byte-compiled function defined in
em-glob.el.gz.
Signature
(eshell-glob-entries PATH GLOBS ONLY-DIRS)
Documentation
Match the entries in PATH against GLOBS.
GLOBS is a list of globs as converted by eshell-glob-convert,
which see.
If ONLY-DIRS is non-nil, only match directories; otherwise, match directories and files.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-glob.el.gz
;; FIXME does this really need to abuse eshell-glob-matches, message-shown?
(defun eshell-glob-entries (path globs only-dirs)
"Match the entries in PATH against GLOBS.
GLOBS is a list of globs as converted by `eshell-glob-convert',
which see.
If ONLY-DIRS is non-nil, only match directories; otherwise, match
directories and files."
(let* ((entries (ignore-errors
(file-name-all-completions "" path)))
(case-fold-search eshell-glob-case-insensitive)
glob glob-remainder recurse-p)
(if (rassq (car globs) eshell-glob-recursive-alist)
(setq recurse-p (car globs)
glob (or (cadr globs)
(eshell-glob-convert-1 "*" t))
glob-remainder (cddr globs))
(setq glob (car globs)
glob-remainder (cdr globs)))
(when (and recurse-p eshell-glob-show-progress)
(message "Building file list...%d so far: %s"
(length eshell-glob-matches) path)
(setq message-shown t))
(when (equal path "./") (setq path ""))
(let ((incl (car glob))
(excl (cdr glob))
dirs rdirs)
(dolist (name entries)
(let* ((len (length name))
(isdir (eq (aref name (1- len)) ?/))
pathname)
(when (let ((fname (directory-file-name name)))
(and (not (and excl (string-match excl fname)))
(string-match incl fname)))
(if glob-remainder
(when isdir
(push (concat path name) dirs))
(when (or (not only-dirs)
(and isdir
(not (and (eq recurse-p 'recurse)
(file-symlink-p
(directory-file-name
(concat path name)))))))
(push (concat path name) eshell-glob-matches))))
(when (and recurse-p isdir
(not (member name '("./" "../")))
(setq pathname (concat path name))
(not (and (eq recurse-p 'recurse)
(file-symlink-p
(directory-file-name pathname)))))
(push pathname rdirs))))
(dolist (dir (nreverse dirs))
(eshell-glob-entries dir glob-remainder only-dirs))
(dolist (rdir (nreverse rdirs))
(eshell-glob-entries rdir globs only-dirs)))))