summaryrefslogtreecommitdiffstats
path: root/man7/glob.7
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man7/glob.756
1 files changed, 28 insertions, 28 deletions
diff --git a/man7/glob.7 b/man7/glob.7
index 466701c..0130c80 100644
--- a/man7/glob.7
+++ b/man7/glob.7
@@ -4,7 +4,7 @@
.\"
.\" 2003-08-24 fix for / by John Kristoff + joey
.\"
-.TH glob 7 2023-03-08 "Linux man-pages 6.05.01"
+.TH glob 7 2023-10-31 "Linux man-pages 6.7"
.SH NAME
glob \- globbing pathnames
.SH DESCRIPTION
@@ -12,11 +12,11 @@ Long ago, in UNIX\ V6, there was a program
.I /etc/glob
that would expand wildcard patterns.
Soon afterward this became a shell built-in.
-.PP
+.P
These days there is also a library routine
.BR glob (3)
that will perform this function for a user program.
-.PP
+.P
The rules are as follows (POSIX.2, 3.13).
.SS Wildcard matching
A string is a wildcard pattern if it contains one of the
@@ -25,14 +25,14 @@ Globbing is the operation
that expands a wildcard pattern into the list of pathnames
matching the pattern.
Matching is defined by:
-.PP
+.P
A \[aq]?\[aq] (not between brackets) matches any single character.
-.PP
+.P
A \[aq]*\[aq] (not between brackets) matches any string,
including the empty string.
-.PP
+.P
.B "Character classes"
-.PP
+.P
An expression "\fI[...]\fP" where the first character after the
leading \[aq][\[aq] is not an \[aq]!\[aq] matches a single character,
namely any of the characters enclosed by the brackets.
@@ -41,9 +41,9 @@ therefore \[aq]]\[aq] can be allowed between the brackets, provided
that it is the first character.
(Thus, "\fI[][!]\fP" matches the
three characters \[aq][\[aq], \[aq]]\[aq], and \[aq]!\[aq].)
-.PP
+.P
.B Ranges
-.PP
+.P
There is one special convention:
two characters separated by \[aq]\-\[aq] denote a range.
(Thus,
@@ -55,15 +55,15 @@ by making it the first or last character between the brackets.
and "\fI[\-\-0]\fP" matches the
three characters \[aq]\-\[aq], \[aq].\[aq], and \[aq]0\[aq],
since \[aq]/\[aq] cannot be matched.)
-.PP
+.P
.B Complementation
-.PP
+.P
An expression "\fI[!...]\fP" matches a single character, namely
any character that is not matched by the expression obtained
by removing the first \[aq]!\[aq] from it.
(Thus, "\fI[!]a\-]\fP" matches any
single character except \[aq]]\[aq], \[aq]a\[aq], and \[aq]\-\[aq].)
-.PP
+.P
One can remove the special meaning of \[aq]?\[aq], \[aq]*\[aq], and \[aq][\[aq]
by preceding them by a backslash,
or,
@@ -79,7 +79,7 @@ A \[aq]/\[aq] in a pathname cannot be matched by a \[aq]?\[aq] or \[aq]*\[aq]
wildcard, or by a range like "\fI[.\-0]\fP".
A range containing an explicit \[aq]/\[aq] character is syntactically incorrect.
(POSIX requires that syntactically incorrect patterns are left unchanged.)
-.PP
+.P
If a filename starts with a \[aq].\[aq],
this character must be matched explicitly.
(Thus, \fIrm\ *\fP will not remove .profile, and \fItar\ c\ *\fP will not
@@ -90,11 +90,11 @@ into the list of matching pathnames" was the original UNIX
definition.
It allowed one to have patterns that expand into
an empty list, as in
-.PP
+.P
.nf
xv \-wait 0 *.gif *.jpg
.fi
-.PP
+.P
where perhaps no *.gif files are present (and this is not
an error).
However, POSIX requires that a wildcard pattern is left
@@ -103,31 +103,31 @@ matching pathnames is empty.
With
.I bash
one can force the classical behavior using this command:
-.PP
+.P
.in +4n
.EX
shopt \-s nullglob
.EE
.in
.\" In Bash v1, by setting allow_null_glob_expansion=true
-.PP
+.P
(Similar problems occur elsewhere.
For example, where old scripts have
-.PP
+.P
.in +4n
.EX
rm \`find . \-name "*\[ti]"\`
.EE
.in
-.PP
+.P
new scripts require
-.PP
+.P
.in +4n
.EX
rm \-f nosuchfile \`find . \-name "*\[ti]"\`
.EE
.in
-.PP
+.P
to avoid error messages from
.I rm
called with an empty argument list.)
@@ -139,7 +139,7 @@ First of all, they match
filenames, rather than text, and secondly, the conventions
are not the same: for example, in a regular expression \[aq]*\[aq] means zero or
more copies of the preceding thing.
-.PP
+.P
Now that regular expressions have bracket expressions where
the negation is indicated by a \[aq]\[ha]\[aq], POSIX has declared the
effect of a wildcard pattern "\fI[\[ha]...]\fP" to be undefined.
@@ -161,21 +161,21 @@ expression: namely (i) the negation, (ii) explicit single characters,
and (iii) ranges.
POSIX specifies ranges in an internationally
more useful way and adds three more types:
-.PP
+.P
(iii) Ranges X\-Y comprise all characters that fall between X
and Y (inclusive) in the current collating sequence as defined
by the
.B LC_COLLATE
category in the current locale.
-.PP
+.P
(iv) Named character classes, like
-.PP
+.P
.nf
[:alnum:] [:alpha:] [:blank:] [:cntrl:]
[:digit:] [:graph:] [:lower:] [:print:]
[:punct:] [:space:] [:upper:] [:xdigit:]
.fi
-.PP
+.P
so that one can say "\fI[[:lower:]]\fP" instead of "\fI[a\-z]\fP", and have
things work in Denmark, too, where there are three letters past \[aq]z\[aq]
in the alphabet.
@@ -183,13 +183,13 @@ These character classes are defined by the
.B LC_CTYPE
category
in the current locale.
-.PP
+.P
(v) Collating symbols, like "\fI[.ch.]\fP" or "\fI[.a-acute.]\fP",
where the string between "\fI[.\fP" and "\fI.]\fP" is a collating
element defined for the current locale.
Note that this may
be a multicharacter element.
-.PP
+.P
(vi) Equivalence class expressions, like "\fI[=a=]\fP",
where the string between "\fI[=\fP" and "\fI=]\fP" is any collating
element from its equivalence class, as defined for the