Function: eshell-extended-glob
eshell-extended-glob is a byte-compiled function defined in
em-glob.el.gz.
Signature
(eshell-extended-glob GLOB)
Documentation
Return a list of files matched by GLOB.
If no files match, signal an error (if eshell-error-if-no-glob
is non-nil), or otherwise return GLOB itself.
This function almost fully supports zsh style filename generation syntax. Things that are not supported are:
^foo for matching everything but foo
(foo~bar) tilde within a parenthesis group
foo<1-10> numeric ranges
foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list
Mainly they are not supported because file matching is done with Emacs regular expressions, and these cannot support the above constructs.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-glob.el.gz
(defun eshell-extended-glob (glob)
"Return a list of files matched by GLOB.
If no files match, signal an error (if `eshell-error-if-no-glob'
is non-nil), or otherwise return GLOB itself.
This function almost fully supports zsh style filename generation
syntax. Things that are not supported are:
^foo for matching everything but foo
(foo~bar) tilde within a parenthesis group
foo<1-10> numeric ranges
foo~x(a|b) (a|b) will be interpreted as a predicate/modifier list
Mainly they are not supported because file matching is done with Emacs
regular expressions, and these cannot support the above constructs."
(let ((globs (eshell-glob-convert glob))
eshell-glob-matches message-shown)
(if (null (cadr globs))
;; If, after examining GLOB, there are no actual globs, just
;; bail out. This can happen for remote file names using "~",
;; like "/ssh:remote:~/file.txt". During parsing, we can't
;; always be sure if the "~" is a home directory reference or
;; part of a glob (e.g. if the argument was assembled from
;; variables).
(if eshell-glob-splice-results (list glob) glob)
(unwind-protect
(apply #'eshell-glob-entries globs)
(if message-shown
(message nil)))
(or (and eshell-glob-matches (sort eshell-glob-matches #'string<))
(if eshell-error-if-no-glob
(error "No matches found: %s" glob)
(if eshell-glob-splice-results
(list glob)
glob))))))