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 generated from GLOB, perhaps looking for DIRS-ONLY.

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.

If this routine fails, it returns nil. Otherwise, it returns a list the form:

   (INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-glob.el.gz
(defun eshell-extended-glob (glob)
  "Return a list of files generated from GLOB, perhaps looking for DIRS-ONLY.
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.

If this routine fails, it returns nil.  Otherwise, it returns a list
the form:

   (INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))"
  (let ((paths (eshell-split-path glob))
        eshell-glob-matches message-shown)
    (unwind-protect
	(if (and (cdr paths)
		 (file-name-absolute-p (car paths)))
	    (eshell-glob-entries (file-name-as-directory (car paths))
				 (cdr paths))
	  (eshell-glob-entries (file-name-as-directory ".") paths))
      (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)
	  glob))))