159 lines
7.0 KiB
HTML
159 lines
7.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>fnmatch</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
|
|
<basefont size="3"> <a name="fnmatch"></a> <a name="tag_03_175"></a><!-- fnmatch -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_175_01"></a>NAME</h4>
|
|
|
|
<blockquote>fnmatch - match a filename or a pathname</blockquote>
|
|
|
|
<h4><a name="tag_03_175_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>#include <<a href="../basedefs/fnmatch.h.html">fnmatch.h</a>><br>
|
|
<br>
|
|
int fnmatch(const char *</tt><i>pattern</i><tt>, const char *</tt><i>string</i><tt>, int</tt> <i>flags</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>fnmatch</i>() function shall match patterns as described in the Shell and Utilities volume of
|
|
IEEE Std 1003.1-2001, <a href="../utilities/xcu_chap02.html#tag_02_13_01">Section 2.13.1, Patterns Matching a Single
|
|
Character, and Section 2.13.2, Patterns Matching Multiple Characters</a>. It checks the string specified by the <i>string</i>
|
|
argument to see if it matches the pattern specified by the <i>pattern</i> argument.</p>
|
|
|
|
<p>The <i>flags</i> argument shall modify the interpretation of <i>pattern</i> and <i>string</i>. It is the bitwise-inclusive OR of
|
|
zero or more of the flags defined in <a href="../basedefs/fnmatch.h.html"><i><fnmatch.h></i></a>. If the FNM_PATHNAME flag is
|
|
set in <i>flags</i>, then a slash character ( <tt>'/'</tt> ) in <i>string</i> shall be explicitly matched by a slash in
|
|
<i>pattern</i>; 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.</p>
|
|
|
|
<p>If FNM_NOESCAPE is not set in <i>flags</i>, a backslash character ( <tt>'\'</tt> ) in <i>pattern</i> followed by any other
|
|
character shall match that second character in <i>string</i>. In particular, <tt>"\\"</tt> shall match a backslash in
|
|
<i>string</i>. If FNM_NOESCAPE is set, a backslash character shall be treated as an ordinary character.</p>
|
|
|
|
<p>If FNM_PERIOD is set in <i>flags</i>, then a leading period ( <tt>'.'</tt> ) in <i>string</i> shall match a period in
|
|
<i>pattern</i>; as described by rule 2 in the Shell and Utilities volume of IEEE Std 1003.1-2001, <a href=
|
|
"../utilities/xcu_chap02.html#tag_02_13_02">Section 2.13.3, Patterns Used for Filename Expansion</a> where the location of
|
|
"leading" is indicated by the value of FNM_PATHNAME:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>If FNM_PATHNAME is set, a period is "leading" if it is the first character in <i>string</i> or if it immediately follows a
|
|
slash.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If FNM_PATHNAME is not set, a period is "leading" only if it is the first character of <i>string</i>.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>If FNM_PERIOD is not set, then no special restrictions are placed on matching a period.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>If <i>string</i> matches the pattern specified by <i>pattern</i>, then <i>fnmatch</i>() shall return 0. If there is no match,
|
|
<i>fnmatch</i>() shall return FNM_NOMATCH, which is defined in <a href="../basedefs/fnmatch.h.html"><i><fnmatch.h></i></a>.
|
|
If an error occurs, <i>fnmatch</i>() shall return another non-zero value.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>No errors are defined.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_175_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>fnmatch</i>() function has two major uses. It could be used by an application or utility that needs to read a directory
|
|
and apply a pattern against each entry. The <a href="../utilities/find.html"><i>find</i></a> utility is an example of this. It can
|
|
also be used by the <a href="../utilities/pax.html"><i>pax</i></a> utility to process its <i>pattern</i> operands, or by
|
|
applications that need to match strings in a similar manner.</p>
|
|
|
|
<p>The name <i>fnmatch</i>() is intended to imply <i>filename</i> match, rather than <i>pathname</i> match. The default action of
|
|
this function is to match filenames, rather than pathnames, since it gives no special significance to the slash character. With the
|
|
FNM_PATHNAME flag, <i>fnmatch</i>() does match pathnames, but without tilde expansion, parameter expansion, or special treatment
|
|
for a period at the beginning of a filename.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>This function replaced the REG_FILENAME flag of <a href="../functions/regcomp.html"><i>regcomp</i>()</a> in early proposals of
|
|
this volume of IEEE Std 1003.1-2001. It provides virtually the same functionality as the <a href=
|
|
"../functions/regcomp.html"><i>regcomp</i>()</a> and <a href="../functions/regexec.html"><i>regexec</i>()</a> functions using the
|
|
REG_FILENAME and REG_FSLASH flags (the REG_FSLASH flag was proposed for <a href="../functions/regcomp.html"><i>regcomp</i>()</a>,
|
|
and would have had the opposite effect from FNM_PATHNAME), but with a simpler function and less system overhead.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="glob.html"><i>glob</i>()</a> , <a href="wordexp.html"><i>wordexp</i>()</a> , the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/fnmatch.h.html"><i><fnmatch.h></i></a>, the Shell and Utilities volume
|
|
of IEEE Std 1003.1-2001</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4. Derived from the ISO POSIX-2 standard.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_175_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Moved from POSIX2 C-language Binding to BASE.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|