man-pages/man3/fnmatch.3.html
2021-03-31 01:06:50 +01:00

201 lines
5.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of FNMATCH</TITLE>
</HEAD><BODY>
<H1>FNMATCH</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
fnmatch - match filename or pathname
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/fnmatch.h">fnmatch.h</A>&gt;</B>
<B>int fnmatch(const char *</B><I>pattern</I><B>, const char *</B><I>string</I><B>, int </B><I>flags</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>fnmatch</B>()
function checks whether the
<I>string</I>
argument matches the
<I>pattern</I>
argument, which is a shell wildcard pattern (see
<B><A HREF="/cgi-bin/man/man2html?7+glob">glob</A></B>(7)).
<P>
The
<I>flags</I>
argument modifies the behavior; it is the bitwise OR of zero or more
of the following flags:
<DL COMPACT>
<DT id="1"><B>FNM_NOESCAPE</B>
<DD>
If this flag is set, treat backslash as an ordinary character,
instead of an escape character.
<DT id="2"><B>FNM_PATHNAME</B>
<DD>
If this flag is set, match a slash in
<I>string</I>
only with a slash in
<I>pattern</I>
and not by an asterisk (*) or a question mark (?) metacharacter,
nor by a bracket expression ([]) containing a slash.
<DT id="3"><B>FNM_PERIOD</B>
<DD>
If this flag is set, a leading period in
<I>string</I>
has to be matched exactly by a period in
<I>pattern</I>.
A period is considered to be leading if it is the first character in
<I>string</I>,
or if both
<B>FNM_PATHNAME</B>
is set and the period immediately follows a slash.
<DT id="4"><B>FNM_FILE_NAME</B>
<DD>
This is a GNU synonym for
<B>FNM_PATHNAME</B>.
<DT id="5"><B>FNM_LEADING_DIR</B>
<DD>
If this flag (a GNU extension) is set, the pattern is considered to be
matched if it matches an initial segment of
<I>string</I>
which is followed by a slash.
This flag is mainly for the internal
use of glibc and is implemented only in certain cases.
<DT id="6"><B>FNM_CASEFOLD</B>
<DD>
If this flag (a GNU extension) is set, the pattern is matched
case-insensitively.
<DT id="7"><B>FNM_EXTMATCH</B>
<DD>
If this flag (a GNU extension) is set, extended patterns are
supported, as introduced by 'ksh' and now supported by other shells.
The extended format is as follows, with <I>pattern-list</I>
being a '|' separated list of patterns.
<DT id="8">'?(<I>pattern-list</I>)'<DD>
The pattern matches if zero or one occurrences of any of the
patterns in the <I>pattern-list</I> match the input <I>string</I>.
<DT id="9">'*(<I>pattern-list</I>)'<DD>
The pattern matches if zero or more occurrences of any of the
patterns in the <I>pattern-list</I> match the input <I>string</I>.
<DT id="10">'+(<I>pattern-list</I>)'<DD>
The pattern matches if one or more occurrences of any of the
patterns in the <I>pattern-list</I> match the input <I>string</I>.
<DT id="11">'@(<I>pattern-list</I>)'<DD>
The pattern matches if exactly one occurrence of any of the
patterns in the <I>pattern-list</I> match the input <I>string</I>.
<DT id="12">'!(<I>pattern-list</I>)'<DD>
The pattern matches if the input <I>string</I> cannot be matched with
any of the patterns in the <I>pattern-list</I>.
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
Zero if
<I>string</I>
matches
<I>pattern</I>,
<B>FNM_NOMATCH</B>
if there is no match or another nonzero value if there is an error.
<A NAME="lbAF">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>fnmatch</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe env locale<BR></TD></TR>
</TABLE>
<A NAME="lbAG">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008, POSIX.2.
The
<B>FNM_FILE_NAME</B>, <B>FNM_LEADING_DIR</B>, and <B>FNM_CASEFOLD</B>
flags are GNU extensions.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+sh">sh</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+glob">glob</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+scandir">scandir</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+wordexp">wordexp</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+glob">glob</A></B>(7)
<A NAME="lbAI">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="13"><A HREF="#lbAB">NAME</A><DD>
<DT id="14"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="15"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="16"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="17"><A HREF="#lbAF">ATTRIBUTES</A><DD>
<DT id="18"><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT id="19"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="20"><A HREF="#lbAI">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:43 GMT, March 31, 2021
</BODY>
</HTML>