diff options
Diffstat (limited to 'man7/glob.7')
| -rw-r--r-- | man7/glob.7 | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/man7/glob.7 b/man7/glob.7 index c27eda9451..81a073c0f6 100644 --- a/man7/glob.7 +++ b/man7/glob.7 @@ -38,9 +38,11 @@ that will perform this function for a user program. The rules are as follows (POSIX.2, 3.13). .SH "WILDCARD MATCHING" A string is a wildcard pattern if it contains one of the -characters `?', `*' or `['. Globbing is the operation +characters `?', `*' or `['. +Globbing is the operation that expands a wildcard pattern into the list of pathnames -matching the pattern. Matching is defined by: +matching the pattern. +Matching is defined by: A `?' (not between brackets) matches any single character. @@ -52,8 +54,8 @@ leading `[' is not an `!' matches a single character, namely any of the characters enclosed by the brackets. The string enclosed by the brackets cannot be empty; therefore `]' can be allowed between the brackets, provided -that it is the first character. (Thus, `[][!]' matches the -three characters `[', `]' and `!'.) +that it is the first character. +(Thus, `[][!]' matches the three characters `[', `]' and `!'.) .SS Ranges There is one special convention: two characters separated by `\-' denote a range. @@ -76,8 +78,10 @@ Between brackets these characters stand for themselves. Thus, `[[?*\e]' matches the four characters `[', `?', `*' and `\e'. .SH PATHNAMES Globbing is applied on each of the components of a pathname -separately. A `/' in a pathname cannot be matched by a `?' or `*' -wildcard, or by a range like `[.\-0]'. A range cannot contain an +separately. +A `/' in a pathname cannot be matched by a `?' or `*' +wildcard, or by a range like `[.\-0]'. +A range cannot contain an explicit `/' character; this would lead to a syntax error. If a filename starts with a `.', this character must be matched explicitly. @@ -86,7 +90,8 @@ archive all your files; `tar c .' is better.) .SH "EMPTY LISTS" The nice and simple rule given above: `expand a wildcard pattern into the list of matching pathnames' was the original Unix -definition. It allowed one to have patterns that expand into +definition. +It allowed one to have patterns that expand into an empty list, as in .br .nf @@ -102,7 +107,8 @@ With one can force the classical behaviour by setting .IR allow_null_glob_expansion=true . -(Similar problems occur elsewhere. E.g., where old scripts have +(Similar problems occur elsewhere. +E.g., where old scripts have .br .nf rm `find . \-name "*~"` @@ -118,7 +124,8 @@ called with an empty argument list.) .SH NOTES .SS Regular expressions Note that wildcard patterns are not regular expressions, -although they are a bit similar. First of all, they match +although they are a bit similar. +First of all, they match filenames, rather than text, and secondly, the conventions are not the same: e.g., in a regular expression `*' means zero or more copies of the preceding thing. @@ -132,7 +139,8 @@ so that `[\ \-%]' stands for `[\ !"#$%]' and `[a\-z]' stands for "any lowercase letter". Some Unix implementations generalized this so that a range X\-Y stands for the set of characters with code between the codes for -X and for Y. However, this requires the user to know the +X and for Y. +However, this requires the user to know the character coding in use on the local system, and moreover, is not convenient if the collating sequence for the local alphabet differs from the ordering of the character codes. @@ -140,7 +148,8 @@ Therefore, POSIX extended the bracket notation greatly, both for wildcard patterns and for regular expressions. In the above we saw three types of items that can occur in a bracket expression: namely (i) the negation, (ii) explicit single characters, -and (iii) ranges. POSIX specifies ranges in an internationally +and (iii) ranges. +POSIX specifies ranges in an internationally more useful way and adds three more types: (iii) Ranges X\-Y comprise all characters that fall between X @@ -163,13 +172,15 @@ in the current locale. (v) Collating symbols, like `[.ch.]' or `[.a-acute.]', where the string between `[.' and `.]' is a collating -element defined for the current locale. Note that this may +element defined for the current locale. +Note that this may be a multi-character element. (vi) Equivalence class expressions, like `[=a=]', where the string between `[=' and `=]' is any collating element from its equivalence class, as defined for the -current locale. For example, `[[=a=]]' might be equivalent +current locale. +For example, `[[=a=]]' might be equivalent to `[a����]' (warning: Latin-1 here), that is, to `[a[.a-acute.][.a-grave.][.a-umlaut.][.a-circumflex.]]'. .SH "SEE ALSO" |
