diff options
| author | Jim Porter | 2022-03-08 17:07:26 -0800 |
|---|---|---|
| committer | Eli Zaretskii | 2022-04-17 10:27:39 +0300 |
| commit | bbb92dde01ec3fc46b24247fb2d181a21dbcc40a (patch) | |
| tree | 46c8eaede0f5d432d447fefb768338f9e847ef4a /doc/misc/eshell.texi | |
| parent | 265f4ef70233c4708cbbdeb1850541570c40fdd6 (diff) | |
| download | emacs-bbb92dde01ec3fc46b24247fb2d181a21dbcc40a.tar.gz emacs-bbb92dde01ec3fc46b24247fb2d181a21dbcc40a.zip | |
Add unit tests and documentation for Eshell pattern-based globs
* lisp/eshell/em-glob.el (eshell-extended-glob): Fix docstring.
(eshell-glob-entries): Refer to '**/' in error (technically, '**' can
end a glob, but it means the same thing as '*'). (Bug#54470)
* test/lisp/eshell/em-glob-tests.el: New file.
* doc/misc/eshell.texi (Globbing): Document pattern-based globs.
Diffstat (limited to 'doc/misc/eshell.texi')
| -rw-r--r-- | doc/misc/eshell.texi | 94 |
1 files changed, 85 insertions, 9 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index 372e4c3ffbd..648917f62d1 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi | |||
| @@ -1089,15 +1089,91 @@ the result of @var{expr} is not a string or a sequence. | |||
| 1089 | 1089 | ||
| 1090 | @node Globbing | 1090 | @node Globbing |
| 1091 | @section Globbing | 1091 | @section Globbing |
| 1092 | Eshell's globbing syntax is very similar to that of Zsh. Users coming | 1092 | @vindex eshell-glob-case-insensitive |
| 1093 | from Bash can still use Bash-style globbing, as there are no | 1093 | Eshell's globbing syntax is very similar to that of Zsh |
| 1094 | incompatibilities. Most globbing is pattern-based expansion, but there | 1094 | (@pxref{Filename Generation, , , zsh, The Z Shell Manual}). Users |
| 1095 | is also predicate-based expansion. @xref{Filename Generation, , , | 1095 | coming from Bash can still use Bash-style globbing, as there are no |
| 1096 | zsh, The Z Shell Manual}, | 1096 | incompatibilities. |
| 1097 | for full syntax. To customize the syntax and behavior of globbing in | 1097 | |
| 1098 | Eshell see the Customize@footnote{@xref{Easy Customization, , , emacs, | 1098 | By default, globs are case sensitive, except on MS-DOS/MS-Windows |
| 1099 | The GNU Emacs Manual}.} | 1099 | systems. You can control this behavior via the |
| 1100 | groups ``eshell-glob'' and ``eshell-pred''. | 1100 | @code{eshell-glob-case-insensitive} option. You can further customize |
| 1101 | the syntax and behavior of globbing in Eshell via the Customize group | ||
| 1102 | ``eshell-glob'' (@pxref{Easy Customization, , , emacs, The GNU Emacs | ||
| 1103 | Manual}). | ||
| 1104 | |||
| 1105 | @table @samp | ||
| 1106 | |||
| 1107 | @item * | ||
| 1108 | Matches any string (including the empty string). For example, | ||
| 1109 | @samp{*.el} matches any file with the @file{.el} extension. | ||
| 1110 | |||
| 1111 | @item ? | ||
| 1112 | Matches any single character. For example, @samp{?at} matches | ||
| 1113 | @file{cat} and @file{bat}, but not @file{goat}. | ||
| 1114 | |||
| 1115 | @item **/ | ||
| 1116 | Matches zero or more subdirectories in a file name. For example, | ||
| 1117 | @samp{**/foo.el} matches @file{foo.el}, @file{bar/foo.el}, | ||
| 1118 | @file{bar/baz/foo.el}, etc. Note that this cannot be combined with | ||
| 1119 | any other patterns in the same file name segment, so while | ||
| 1120 | @samp{foo/**/bar.el} is allowed, @samp{foo**/bar.el} is not. | ||
| 1121 | |||
| 1122 | @item ***/ | ||
| 1123 | Like @samp{**/}, but follows symlinks as well. | ||
| 1124 | |||
| 1125 | @cindex character sets, in Eshell glob patterns | ||
| 1126 | @cindex character classes, in Eshell glob patterns | ||
| 1127 | @item [ @dots{} ] | ||
| 1128 | Defines a @dfn{character set} (@pxref{Regexps, , , emacs, The GNU | ||
| 1129 | Emacs Manual}). A character set matches characters between the two | ||
| 1130 | brackets; for example, @samp{[ad]} matches @file{a} and @file{d}. You | ||
| 1131 | can also include ranges of characters in the set by separating the | ||
| 1132 | start and end with @samp{-}. Thus, @samp{[a-z]} matches any | ||
| 1133 | lower-case @acronym{ASCII} letter. Note that, unlike in Zsh, | ||
| 1134 | character ranges are interpreted in the Unicode codepoint order, not | ||
| 1135 | in the locale-dependent collation order. | ||
| 1136 | |||
| 1137 | Additionally, you can include @dfn{character classes} in a character | ||
| 1138 | set. A @samp{[:} and balancing @samp{:]} enclose a character class | ||
| 1139 | inside a character set. For instance, @samp{[[:alnum:]]} | ||
| 1140 | matches any letter or digit. @xref{Char Classes, , , elisp, The Emacs | ||
| 1141 | Lisp Reference Manual}, for a list of character classes. | ||
| 1142 | |||
| 1143 | @cindex complemented character sets, in Eshell glob patterns | ||
| 1144 | @item [^ @dots{} ] | ||
| 1145 | Defines a @dfn{complemented character set}. This behaves just like a | ||
| 1146 | character set, but matches any character @emph{except} the ones | ||
| 1147 | specified. | ||
| 1148 | |||
| 1149 | @cindex groups, in Eshell glob patterns | ||
| 1150 | @item ( @dots{} ) | ||
| 1151 | Defines a @dfn{group}. A group matches the pattern between @samp{(} | ||
| 1152 | and @samp{)}. Note that a group can only match a single file name | ||
| 1153 | component, so a @samp{/} inside a group will signal an error. | ||
| 1154 | |||
| 1155 | @item @var{x}|@var{y} | ||
| 1156 | Inside of a group, matches either @var{x} or @var{y}. For example, | ||
| 1157 | @samp{e(m|sh)-*} matches any file beginning with @file{em-} or | ||
| 1158 | @file{esh-}. | ||
| 1159 | |||
| 1160 | @item @var{x}# | ||
| 1161 | Matches zero or more copies of the glob pattern @var{x}. For example, | ||
| 1162 | @samp{fo#.el} matches @file{f.el}, @file{fo.el}, @file{foo.el}, etc. | ||
| 1163 | |||
| 1164 | @item @var{x}## | ||
| 1165 | Matches one or more copies of the glob pattern @var{x}. Thus, | ||
| 1166 | @samp{fo#.el} matches @file{fo.el}, @file{foo.el}, @file{fooo.el}, | ||
| 1167 | etc. | ||
| 1168 | |||
| 1169 | @item @var{x}~@var{y} | ||
| 1170 | Matches anything that matches the pattern @var{x} but not @var{y}. For | ||
| 1171 | example, @samp{[[:digit:]]#~4?} matches @file{1} and @file{12}, but | ||
| 1172 | not @file{42}. Note that unlike in Zsh, only a single @samp{~} | ||
| 1173 | operator can be used in a pattern, and it cannot be inside of a group | ||
| 1174 | like @samp{(@var{x}~@var{y})}. | ||
| 1175 | |||
| 1176 | @end table | ||
| 1101 | 1177 | ||
| 1102 | @node Input/Output | 1178 | @node Input/Output |
| 1103 | @chapter Input/Output | 1179 | @chapter Input/Output |