Debian Codegraph @

upstream/fedora-44/man3/fnmatch.3

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