aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc/eshell.texi
diff options
context:
space:
mode:
authorJim Porter2022-03-08 17:07:26 -0800
committerEli Zaretskii2022-04-17 10:27:39 +0300
commitbbb92dde01ec3fc46b24247fb2d181a21dbcc40a (patch)
tree46c8eaede0f5d432d447fefb768338f9e847ef4a /doc/misc/eshell.texi
parent265f4ef70233c4708cbbdeb1850541570c40fdd6 (diff)
downloademacs-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.texi94
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
1092Eshell's globbing syntax is very similar to that of Zsh. Users coming 1092@vindex eshell-glob-case-insensitive
1093from Bash can still use Bash-style globbing, as there are no 1093Eshell's globbing syntax is very similar to that of Zsh
1094incompatibilities. Most globbing is pattern-based expansion, but there 1094(@pxref{Filename Generation, , , zsh, The Z Shell Manual}). Users
1095is also predicate-based expansion. @xref{Filename Generation, , , 1095coming from Bash can still use Bash-style globbing, as there are no
1096zsh, The Z Shell Manual}, 1096incompatibilities.
1097for full syntax. To customize the syntax and behavior of globbing in 1097
1098Eshell see the Customize@footnote{@xref{Easy Customization, , , emacs, 1098By default, globs are case sensitive, except on MS-DOS/MS-Windows
1099The GNU Emacs Manual}.} 1099systems. You can control this behavior via the
1100groups ``eshell-glob'' and ``eshell-pred''. 1100@code{eshell-glob-case-insensitive} option. You can further customize
1101the syntax and behavior of globbing in Eshell via the Customize group
1102``eshell-glob'' (@pxref{Easy Customization, , , emacs, The GNU Emacs
1103Manual}).
1104
1105@table @samp
1106
1107@item *
1108Matches any string (including the empty string). For example,
1109@samp{*.el} matches any file with the @file{.el} extension.
1110
1111@item ?
1112Matches any single character. For example, @samp{?at} matches
1113@file{cat} and @file{bat}, but not @file{goat}.
1114
1115@item **/
1116Matches 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
1119any 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 ***/
1123Like @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{} ]
1128Defines a @dfn{character set} (@pxref{Regexps, , , emacs, The GNU
1129Emacs Manual}). A character set matches characters between the two
1130brackets; for example, @samp{[ad]} matches @file{a} and @file{d}. You
1131can also include ranges of characters in the set by separating the
1132start and end with @samp{-}. Thus, @samp{[a-z]} matches any
1133lower-case @acronym{ASCII} letter. Note that, unlike in Zsh,
1134character ranges are interpreted in the Unicode codepoint order, not
1135in the locale-dependent collation order.
1136
1137Additionally, you can include @dfn{character classes} in a character
1138set. A @samp{[:} and balancing @samp{:]} enclose a character class
1139inside a character set. For instance, @samp{[[:alnum:]]}
1140matches any letter or digit. @xref{Char Classes, , , elisp, The Emacs
1141Lisp Reference Manual}, for a list of character classes.
1142
1143@cindex complemented character sets, in Eshell glob patterns
1144@item [^ @dots{} ]
1145Defines a @dfn{complemented character set}. This behaves just like a
1146character set, but matches any character @emph{except} the ones
1147specified.
1148
1149@cindex groups, in Eshell glob patterns
1150@item ( @dots{} )
1151Defines a @dfn{group}. A group matches the pattern between @samp{(}
1152and @samp{)}. Note that a group can only match a single file name
1153component, so a @samp{/} inside a group will signal an error.
1154
1155@item @var{x}|@var{y}
1156Inside 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}#
1161Matches 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}##
1165Matches 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},
1167etc.
1168
1169@item @var{x}~@var{y}
1170Matches anything that matches the pattern @var{x} but not @var{y}. For
1171example, @samp{[[:digit:]]#~4?} matches @file{1} and @file{12}, but
1172not @file{42}. Note that unlike in Zsh, only a single @samp{~}
1173operator can be used in a pattern, and it cannot be inside of a group
1174like @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