fix typo in changelog
[debian/sudo] / fnmatch.3
1 .\"     $OpenBSD: fnmatch.3,v 1.7 1999/06/05 04:47:41 aaron Exp $
2 .\"
3 .\" Copyright (c) 1989, 1991, 1993
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to Berkeley by
7 .\" Guido van Rossum.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)fnmatch.3   8.3 (Berkeley) 4/28/95
33 .\"
34 .Dd April 28, 1995
35 .Dt FNMATCH 3
36 .Os
37 .Sh NAME
38 .Nm fnmatch
39 .Nd match filename or pathname using shell globbing rules
40 .Sh SYNOPSIS
41 .Fd #include <fnmatch.h>
42 .Ft int
43 .Fn fnmatch "const char *pattern" "const char *string" "int flags"
44 .Sh DESCRIPTION
45 The
46 .Fn fnmatch
47 function
48 matches patterns according to the globbing rules used by the shell.
49 It checks the string specified by the
50 .Fa string
51 argument to see if it matches the pattern specified by the
52 .Fa pattern
53 argument.
54 .Pp
55 The
56 .Fa flags
57 argument modifies the interpretation of
58 .Fa pattern
59 and
60 .Fa string .
61 The value of
62 .Fa flags
63 is the bitwise inclusive
64 .Tn OR
65 of any of the following
66 constants, which are defined in the include file
67 .Aq Pa fnmatch.h .
68 .Bl -tag -width FNM_PATHNAME
69 .It Dv FNM_NOESCAPE
70 Normally, every occurrence of a backslash
71 .Pq Sq \e
72 followed by a character in
73 .Fa pattern
74 is replaced by that character.
75 This is done to negate any special meaning for the character.
76 If the
77 .Dv FNM_NOESCAPE
78 flag is set, a backslash character is treated as an ordinary character.
79 .It Dv FNM_PATHNAME
80 Slash characters in
81 .Fa string
82 must be explicitly matched by slashes in
83 .Fa pattern .
84 If this flag is not set, then slashes are treated as regular characters.
85 .It Dv FNM_PERIOD
86 Leading periods in
87 .Fa string
88 must be explicitly matched by periods in
89 .Fa pattern .
90 If this flag is not set, then leading periods are treated as regular
91 characters.
92 The definition of
93 .Dq leading
94 is related to the specification of
95 .Dv FNM_PATHNAME .
96 A period is always leading
97 if it is the first character in
98 .Fa string .
99 Additionally, if
100 .Dv FNM_PATHNAME
101 is set,
102 a period is leading
103 if it immediately follows a slash.
104 .It Dv FNM_LEADING_DIR
105 Ignore
106 .Nm /*
107 rest after successful
108 .Fa pattern
109 matching.
110 .It Dv FNM_CASEFOLD
111 Ignore case distinctions in both the
112 .Fa pattern
113 and the
114 .Fa string .
115 .El
116 .Sh RETURN VALUES
117 The
118 .Fn fnmatch
119 function returns zero if
120 .Fa string
121 matches the pattern specified by
122 .Fa pattern ,
123 otherwise, it returns the value
124 .Dv FNM_NOMATCH .
125 .Sh SEE ALSO
126 .Xr sh 1 ,
127 .Xr glob 3 ,
128 .Xr regex 3
129 .Sh STANDARDS
130 The
131 .Fn fnmatch
132 function conforms to
133 .St -p1003.2-92 .
134 .Sh HISTORY
135 The
136 .Fn fnmatch
137 function first appeared in
138 .Bx 4.4 .
139 .Sh BUGS
140 The pattern
141 .Ql *
142 matches the empty string, even if
143 .Dv FNM_PATHNAME
144 is specified.