2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission
3 .\" to reproduce portions of its copyrighted documentation.
5 .\" Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group,
9 .\" have given us permission to reprint portions of their documentation. In the
10 .\" following statement, the phrase "this text" refers to portions of the system
13 .\" Portions of this text are reprinted and reproduced in electronic form in the
14 .\" Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for
15 .\" Information Technology -- Portable Operating System Interface (POSIX),
16 .\" The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the
17 .\" Institute of Electrical and Electronics Engineers, Inc and The Open Group.
19 .\" In the event of any discrepancy between these versions and the original
20 .\" IEEE and The Open Group Standard, the original IEEE and The Open Group
21 .\" Standard is the referee document.
23 .\" The original Standard can be obtained online at
24 .\" http://www.opengroup.org/unix/online.html.
26 .\" This notice shall appear on any product containing this material.
28 .\" The contents of this file are subject to the terms of the
29 .\" Common Development and Distribution License (the "License").
30 .\" You may not use this file except in compliance with the License.
32 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
33 .\" or http://www.opensolaris.org/os/licensing.
34 .\" See the License for the specific language governing permissions
35 .\" and limitations under the License.
37 .\" When distributing Covered Code, include this CDDL HEADER in each
38 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
39 .\" If applicable, add the following below this CDDL HEADER, with the
40 .\" fields enclosed by brackets "[]" replaced with your own identifying
41 .\" information: Portions Copyright [yyyy] [name of copyright owner]
44 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved
46 .\" Copyright 2017 Nexenta Systems, Inc.
53 .Nd match filename or path name
60 .Fa "const char *pattern"
61 .Fa "const char *string"
67 function matches patterns as described on the
70 .Po with the exceptions noted in the
75 argument to see if it matches the
81 argument modifies the interpretation of
85 It is the bitwise inclusive OR of zero or more of the following flags defined in
88 .Bl -tag -width "FNM_LEADING_DIR"
94 will be explicitly matched by a slash in
96 it will not be matched by either the asterisk
100 special characters, nor by a bracket
104 If not set, the slash character is treated as an ordinary character.
105 .It Dv FNM_IGNORECASE
108 will be transliterated to lower case before doing the actual match.
109 This transliteration is done using
111 using the locale of the current thread.
112 If no locale is set, then the global locale is used instead.
114 If not set, the match will use
116 with no changes, making the match case-sensitive.
118 For compatibility with
126 flag having the same meaning.
128 If not set, a backslash character
132 followed by any other character will match that second character in
136 will match a backslash in
139 If set, a backslash character will be treated as an ordinary character.
141 If set, a leading period in
143 will match a period in
145 where the location of
147 is indicated by the value of
155 if it is the first character in
157 or if it immediately follows a slash.
161 is not set, a period is
163 only if it is the first character of
167 If not set, no special restrictions are placed on matching a period.
168 .It Dv FNM_LEADING_DIR
171 matches initial segment of
173 which is followed by a slash.
178 matches the pattern specified by
183 If there is no match,
187 which is defined in the header
191 returns another non-zero value.
195 function has two major uses.
196 It could be used by an application or utility that needs to read a directory and
197 apply a pattern against each entry.
200 utility is an example of this.
201 It can also be used by the
203 utility to process its
205 operands, or by applications that need to match strings in a similar manner.
214 The default action of this function is to match filenames, rather than path
215 names, since it gives no special significance to the slash character.
220 does match path names, but without tilde expansion, parameter expansion, or
221 special treatment for period at the beginning of a filename.
222 .Sh CODE SET INDEPENDENCE
224 .Sh INTERFACE STABILITY
227 .Sy MT-Safe with exceptions
231 function can be used safely in multithreaded applications, as long as
233 is not being called to change the locale.
244 The current implementation of the
250 Collating symbol expressions, equivalence class expressions and
251 character class expressions are not supported.
255 matches the empty string, even if