2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
44 .\" Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved
45 .\" Copyright 2017 Nexenta Systems, Inc.
52 .Nd match filename or path name
59 .Fa "const char *pattern"
60 .Fa "const char *string"
66 function matches patterns as described on the
69 .Po with the exceptions noted in the
74 argument to see if it matches the
80 argument modifies the interpretation of
84 It is the bitwise inclusive OR of zero or more of the following flags defined in
87 .Bl -tag -width "FNM_LEADING_DIR"
93 will be explicitly matched by a slash in
95 it will not be matched by either the asterisk
99 special characters, nor by a bracket
103 If not set, the slash character is treated as an ordinary character.
104 .It Dv FNM_IGNORECASE
107 will be transliterated to lower case before doing the actual match.
108 This transliteration is done using
110 using the locale of the current thread.
111 If no locale is set, then the global locale is used instead.
113 If not set, the match will use
115 with no changes, making the match case-sensitive.
117 For compatibility with
125 flag having the same meaning.
127 If not set, a backslash character
131 followed by any other character will match that second character in
135 will match a backslash in
138 If set, a backslash character will be treated as an ordinary character.
140 If set, a leading period in
142 will match a period in
144 where the location of
146 is indicated by the value of
154 if it is the first character in
156 or if it immediately follows a slash.
160 is not set, a period is
162 only if it is the first character of
166 If not set, no special restrictions are placed on matching a period.
167 .It Dv FNM_LEADING_DIR
170 matches initial segment of
172 which is followed by a slash.
177 matches the pattern specified by
182 If there is no match,
186 which is defined in the header
190 returns another non-zero value.
194 function has two major uses.
195 It could be used by an application or utility that needs to read a directory and
196 apply a pattern against each entry.
199 utility is an example of this.
200 It can also be used by the
202 utility to process its
204 operands, or by applications that need to match strings in a similar manner.
213 The default action of this function is to match filenames, rather than path
214 names, since it gives no special significance to the slash character.
219 does match path names, but without tilde expansion, parameter expansion, or
220 special treatment for period at the beginning of a filename.
221 .Sh CODE SET INDEPENDENCE
223 .Sh INTERFACE STABILITY
226 .Sy MT-Safe with exceptions
230 function can be used safely in multithreaded applications, as long as
232 is not being called to change the locale.
243 The current implementation of the
249 Collating symbol expressions, equivalence class expressions and
250 character class expressions are not supported.
254 matches the empty string, even if