]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/fnmatch.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / fnmatch.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" Modified Sat Jul 24 19:35:54 1993 by Rik Faith (faith@cs.unc.edu)
6 .\" Modified Mon Oct 16 00:16:29 2000 following Joseph S. Myers
7 .\"
8 .TH FNMATCH 3 2021-03-22 "Linux man-pages (unreleased)"
9 .SH NAME
10 fnmatch \- match filename or pathname
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ", " \-lc )
14 .SH SYNOPSIS
15 .nf
16 .B #include <fnmatch.h>
17 .PP
18 .BI "int fnmatch(const char *" "pattern" ", const char *" string ", int " flags );
19 .fi
20 .SH DESCRIPTION
21 The
22 .BR fnmatch ()
23 function checks whether the
24 .I string
25 argument matches the
26 .I pattern
27 argument, which is a shell wildcard pattern (see
28 .BR glob (7)).
29 .PP
30 The
31 .I flags
32 argument modifies the behavior; it is the bitwise OR of zero or more
33 of the following flags:
34 .TP
35 .B FNM_NOESCAPE
36 If this flag is set, treat backslash as an ordinary character,
37 instead of an escape character.
38 .TP
39 .B FNM_PATHNAME
40 If this flag is set, match a slash in
41 .I string
42 only with a slash in
43 .I pattern
44 and not by an asterisk (*) or a question mark (?) metacharacter,
45 nor by a bracket expression ([]) containing a slash.
46 .TP
47 .B FNM_PERIOD
48 If this flag is set, a leading period in
49 .I string
50 has to be matched exactly by a period in
51 .IR pattern .
52 A period is considered to be leading if it is the first character in
53 .IR string ,
54 or if both
55 .B FNM_PATHNAME
56 is set and the period immediately follows a slash.
57 .TP
58 .B FNM_FILE_NAME
59 This is a GNU synonym for
60 .BR FNM_PATHNAME .
61 .TP
62 .B FNM_LEADING_DIR
63 If this flag (a GNU extension) is set, the pattern is considered to be
64 matched if it matches an initial segment of
65 .I string
66 which is followed by a slash.
67 This flag is mainly for the internal
68 use of glibc and is implemented only in certain cases.
69 .TP
70 .B FNM_CASEFOLD
71 If this flag (a GNU extension) is set, the pattern is matched
72 case-insensitively.
73 .TP
74 .B FNM_EXTMATCH
75 If this flag (a GNU extension) is set, extended patterns are
76 supported, as introduced by \&'ksh' and now supported by other shells.
77 The extended format is as follows, with \fIpattern\-list\fR
78 being a \&'|' separated list of patterns.
79 .TP
80 \&'?(\fIpattern\-list\fR)'
81 The pattern matches if zero or one occurrences of any of the
82 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
83 .TP
84 \&'*(\fIpattern\-list\fR)'
85 The pattern matches if zero or more occurrences of any of the
86 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
87 .TP
88 \&'+(\fIpattern\-list\fR)'
89 The pattern matches if one or more occurrences of any of the
90 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
91 .TP
92 \&'@(\fIpattern\-list\fR)'
93 The pattern matches if exactly one occurrence of any of the
94 patterns in the \fIpattern\-list\fR match the input \fIstring\fR.
95 .TP
96 \&'!(\fIpattern\-list\fR)'
97 The pattern matches if the input \fIstring\fR cannot be matched with
98 any of the patterns in the \fIpattern\-list\fR.
99 .SH RETURN VALUE
100 Zero if
101 .I string
102 matches
103 .IR pattern ,
104 .B FNM_NOMATCH
105 if there is no match or another nonzero value if there is an error.
106 .SH ATTRIBUTES
107 For an explanation of the terms used in this section, see
108 .BR attributes (7).
109 .ad l
110 .nh
111 .TS
112 allbox;
113 lbx lb lb
114 l l l.
115 Interface Attribute Value
116 T{
117 .BR fnmatch ()
118 T} Thread safety MT-Safe env locale
119 .TE
120 .hy
121 .ad
122 .sp 1
123 .SH STANDARDS
124 POSIX.1-2001, POSIX.1-2008, POSIX.2.
125 The
126 .BR FNM_FILE_NAME ", " FNM_LEADING_DIR ", and " FNM_CASEFOLD
127 flags are GNU extensions.
128 .SH SEE ALSO
129 .BR sh (1),
130 .BR glob (3),
131 .BR scandir (3),
132 .BR wordexp (3),
133 .BR glob (7)