1 .\" Copyright (c) 1989, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95
31 .\" $FreeBSD: head/lib/libc/gen/fnmatch.3 165903 2007-01-09 00:28:16Z imp $
38 .Nd test whether a filename or pathname matches a shell-style pattern
44 .Fn fnmatch "const char *pattern" "const char *string" "int flags"
49 matches patterns according to the rules used by the shell.
50 It checks the string specified by the
52 argument to see if it matches the pattern specified by the
58 argument modifies the interpretation of
64 is the bitwise inclusive
66 of any of the following
67 constants, which are defined in the include file
69 .Bl -tag -width ".Dv FNM_PATHNAME"
71 Normally, every occurrence of a backslash
73 followed by a character in
75 is replaced by that character.
76 This is done to negate any special meaning for the character.
79 flag is set, a backslash character is treated as an ordinary character.
83 must be explicitly matched by slashes in
85 If this flag is not set, then slashes are treated as regular characters.
89 must be explicitly matched by periods in
91 If this flag is not set, then leading periods are treated as regular
95 is related to the specification of
99 if it is the first character in
106 if it immediately follows a slash.
107 .It Dv FNM_LEADING_DIR
110 rest after successful
114 Ignore case distinctions in both the
122 function returns zero if
124 matches the pattern specified by
126 otherwise, it returns the value
133 The current implementation of the
139 Collating symbol expressions, equivalence class expressions and
140 character class expressions are not supported.
144 function first appeared in
149 matches the empty string, even if