Function: eshell-glob-convert
eshell-glob-convert is a byte-compiled function defined in
em-glob.el.gz.
Signature
(eshell-glob-convert GLOB)
Documentation
Convert an Eshell glob-pattern GLOB to regexps.
The result is a list of three elements:
1. The base directory to search in.
2. A list containing elements of the following forms:
* Regexp pairs as generated by eshell-glob-convert-1.
* recurse, indicating that searches should recurse into
subdirectories.
* recurse-symlink, like recurse, but also following
symlinks.
3. A boolean indicating whether to match directories only.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-glob.el.gz
(defun eshell-glob-convert (glob)
"Convert an Eshell glob-pattern GLOB to regexps.
The result is a list of three elements:
1. The base directory to search in.
2. A list containing elements of the following forms:
* Regexp pairs as generated by `eshell-glob-convert-1'.
* `recurse', indicating that searches should recurse into
subdirectories.
* `recurse-symlink', like `recurse', but also following
symlinks.
3. A boolean indicating whether to match directories only."
(let ((globs (eshell-split-filename glob))
(isdir (string-suffix-p "/" glob))
start-dir result last-saw-recursion)
(if (and (cdr globs)
(file-name-absolute-p (car globs)))
(setq start-dir (pop globs))
(setq start-dir (file-name-as-directory ".")))
(while globs
;; "~" is an infix globbing character, so one at the start of a
;; glob component must be a literal.
(when (eq (aref (car globs) 0) ?~)
(remove-text-properties 0 1 '(eshell-glob-char) (car globs)))
(if-let* ((recurse (cdr (assoc (car globs) eshell-glob-recursive-alist)))
((eshell--all-glob-chars-p
(string-trim-right (car globs) "/"))))
(if last-saw-recursion
(setcar result recurse)
(push recurse result)
(setq last-saw-recursion t))
(if (or result (eshell--contains-glob-char-p (car globs)))
(push (eshell-glob-convert-1 (car globs) (null (cdr globs)))
result)
;; We haven't seen a glob yet, so instead append to the start
;; directory.
(setq start-dir (concat start-dir (car globs))))
(setq last-saw-recursion nil))
(setq globs (cdr globs)))
(list start-dir
(nreverse result)
isdir)))