|FNMATCH(3P)||POSIX Programmer's Manual||FNMATCH(3P)|
int fnmatch(const char *pattern, const char *string, int flags);
The flags argument shall modify the interpretation of pattern and string. It is the bitwise-inclusive OR of zero or more of the flags defined in <fnmatch.h>. If the FNM_PATHNAME flag is set in flags, then a <slash> character ('/') in string shall be explicitly matched by a <slash> in pattern; it shall not be matched by either the <asterisk> or <question-mark> special characters, nor by a bracket expression. If the FNM_PATHNAME flag is not set, the <slash> character shall be treated as an ordinary character.
If FNM_NOESCAPE is not set in flags, a <backslash> character in pattern followed by any other character shall match that second character in string. In particular, "\\" shall match a <backslash> in string. If pattern ends with an unescaped <backslash>, fnmatch() shall return a non-zero value (indicating either no match or an error). If FNM_NOESCAPE is set, a <backslash> character shall be treated as an ordinary character.
If FNM_PERIOD is set in flags, then a leading <period> ('.') in string shall match a <period> in pattern; as described by rule 2 in the Shell and Utilities volume of POSIX.1‐2017, Section 2.13.3, Patterns Used for Filename Expansion where the location of ``leading'' is indicated by the value of FNM_PATHNAME:
- If FNM_PATHNAME is set, a <period> is ``leading'' if it is the first character in string or if it immediately follows a <slash>.
- If FNM_PATHNAME is not set, a <period> is ``leading'' only if it is the first character of string.
If FNM_PERIOD is not set, then no special restrictions are placed on matching a period.
The following sections are informative.
The name fnmatch() is intended to imply filename match, rather than pathname match. The default action of this function is to match filename strings, rather than pathnames, since it gives no special significance to the <slash> character. With the FNM_PATHNAME flag, fnmatch() does match pathnames, but without tilde expansion, parameter expansion, or special treatment for a <period> at the beginning of a filename.
The Base Definitions volume of POSIX.1‐2017, <fnmatch.h>
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|2017||IEEE/The Open Group|